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
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
- Re: RFC 76 (v2) Builtin: reduce Tom Christiansen
- Re: RFC 76 (v2) Builtin: reduce Graham Barr
- Re: RFC 76 (v2) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v2) Builtin: reduce Peter Scott
- Re: RFC 76 (v2) Builtin: reduce Tom Christiansen
- Re: RFC 76 (v2) Builtin: reduce Damien Neil
- Re: RFC 76 (v2) Builtin: reduce John Porter
- Re: RFC 76 (v2) Builtin: reduce Glenn Linderman
- Re: RFC 76 (v2) Builtin: reduce John Porter
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
- Re: RFC 76 (v2) Builtin: reduce Tom Christiansen
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
- Re: RFC 76 (v2) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v2) Builtin: reduce Tom Christiansen
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
