Tom suggested:

   > Why not just check @numbers?

Hear, hear:

        $sum = @numbers ? reduce ^_+^_, @numbers : 0;

Moreover, I suspect that the usual idiom will be:

        $result = reduce $reducer, $default, @list;

That is:

        $sum = reduce ^_+^_, 0, @numbers;

in which case the "empty list" exception never raises (ahem) its ugly head.

I think the consensus is still that reducing an empty list shall throw an
exception.


Damian

Reply via email to