in reply to Re^2: reduce like iterators
in thread reduce like iterators
Your reduce_list is named similarly to reduce, but bears no resemblance since it doesn't to reduce at all.
reduce allows an arbitrary state to be passed from one pass to another. Your reduce_list doesn't.
reduce can return any value, not just the input. reduce_list can return at most one scalar, and it can only be the input. (That's not very "listy"!)
Because of those reasons, reduce is a general purpose function. (It can implement any other function in List::Util.) Your reduce_list is just grep with access to the last element.
This accounts for the differences with what I suggested it should look like.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: reduce like iterators
by LanX (Saint) on Jan 03, 2011 at 22:08 UTC | |
by ikegami (Patriarch) on Jan 03, 2011 at 23:17 UTC |