Tom Christiansen wrote: > > > $sum = reduce {$_[0]+$_[1]} 0, @numbers || die "Chaos!!"; > > >Note with the || that way, it'll die immediately if @numbers is empty, > >even before destroying the universe. > > Yes, but why are you passing the size of the array in there? 'Cause I'm an idiot, apparently... $sum = reduce {$_[0]+$_[1]} 0, @numbers or die "Chaos!!"; That's better, assuming reduce() returns undef. I'm gonna stop writing examples in emails because I always screw them up... -Nate
- Re: RFC 76 (v2) Builtin: reduce Tom Christiansen
- Re: RFC 76 (v2) Builtin: reduce Graham Barr
- Re: RFC 76 (v2) Builtin: reduce John Porter
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
- Re: RFC 76 (v2) Builtin: reduce Graham Barr
- Re: RFC 76 (v2) Builtin: reduce iain truskett
- Re: RFC 76 (v2) Builtin: reduce John Porter
- Re: RFC 76 (v2) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v2) Builtin: reduce Tom Christiansen
- Re: RFC 76 (v2) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v2) Builtin: reduce Randal L. Schwartz
- Re: RFC 76 (v2) Builtin: reduce Damian Conway
- 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