If you call your bank and ask them what the sum of all of your deposits this month is, and there are none, does your bank say "I can't answer that because there aren't any" or "$0.00"1 ?

You may have a difficult time understanding what the sum of zero items is. The authors of Scalar::Util may have a hard time understanding. But that doesn't prevent some of us from understanding that very clearly and knowing that, mathematically, the sum of zero items is actually well-defined and is simply 0. Similarly, the product of zero items is 1 ($x**0 is 1, and even 0**0 is 1).

It is similar to the author of Term::ReadKey not understanding that for ReadKey($delaySeconds), ReadKey(0) is not a special case and should mean "delay 0 seconds, returning immediately" and it makes no sense for them to have defined ReadKey(0) as "wait forever" and ReadKey(-1) as "wait 0 seconds". Many people have trouble seeing this, but that doesn't mean it isn't true.

1 Or using whatever currency your account is in.

- tye        


In reply to Re^6: List::Util::sum() and empty lists... (obvious) by tye
in thread List::Util::sum() and empty lists... by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.