in reply to Re^7: List::Util::sum() and empty lists... (obvious)
in thread List::Util::sum() and empty lists...
I just wonder what Graham Barr (the original author) has to say about it?
Maybe he did it for consistency. Every function in the module returns undef when given an empty list (except shuffle, which doesn't return a scalar).
Maybe it didn't occur to him to check for that case, since sum is simply sub sum (@) { reduce { $a + $b } @_ }. (While the XS version explicitely returns undef, it probably came after the Perl version.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: List::Util::sum() and empty lists... (obvious)
by Firefly258 (Beadle) on Dec 05, 2006 at 07:09 UTC | |
by ikegami (Patriarch) on Dec 05, 2006 at 08:13 UTC | |
|