Perl-Sensitive Sunglasses | |
PerlMonks |
Re: adding items, but with interim resultsby moritz (Cardinal) |
on Mar 30, 2013 at 16:27 UTC ( [id://1026291]=note: print w/replies, xml ) | Need Help?? |
I know you probably want a solution in Perl 5, but here is one in Perl 6, because it hapepns to be very short:
Enclosing an infix operator like + with square brackets applies it to a list, as if you had written 0 + 1 + 4 + 6. The [\infix] for also returns the intermediate results. Mnemonic: the [\ has the shape of a triangle, just like the list of expressions that is generated from it:
In Section
Seekers of Perl Wisdom
|
|