> > $sum = @numbers ? reduce ^_+^_, @numbers : 0; > > Although we're back to the pain of what happens when @numbers is > really fn(). This is unsatisfactorily nonidempotent (aliapotent? :-) > > $sum = fn() ? reduce ^_+^_, fn() : 0; It would seem likely that most would trade space for time and avoid the second call to fn() with: my @values = fn(); $sum = @values ? reduce ^_+^_, @values : 0; In any case, the preferred option should be to provide a default value: $sum = reduce ^_+^_, 0, @values; which is always cleaner *and* shorter. :-) Damian
- 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