Re: RFC: Should join subsume reduce?by nothingmuch (Priest)
|on Feb 24, 2006 at 00:49 UTC||Need Help??|
reduce is also known fold, and foldr and foldl can be used to implement any of grep, map, join, sum, etc etc etc.
In Haskell Perl's join can be reimplemented as this:
And and similarly we can implement this with List::Util's reduce very elegantly too:
A tutorial on the universality and expressiveness of fold is a wonderful article on this topic. There are some diagrams to assist you in understanding the article, too.
Since you seemed to like to reference c2.com, see The Wheel Gets Reinvented.
Lastly, the argument that adding reduce to Perl will break code is wrong - err, lock and others were added post factum as weak keywords - keywords that are only available if there is no sub by that name in the current package already.
zz zZ Z Z #!perl