good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: reduce like iteratorsby ikegami (Patriarch) |
on Jan 03, 2011 at 19:06 UTC ( [id://880238]=note: print w/replies, xml ) | Need Help?? |
Oops, adjusted:
If one were to make a list version of reduce, the callback would need access to three variables: The list (say $_), the state (say $a), the current value (say $b). The problem could be solved as follows:
(@a may not start with undef for the last two to work properly.) Update: Added everything after the first block of code.
In Section
Seekers of Perl Wisdom
|
|