[Haskell-cafe] foldl vs. foldr
Jan Stolarek
jan.stolarek at p.lodz.pl
Tue Sep 18 14:32:30 CEST 2012
Hi list,
I have yet another question about folds. Reading here and there I encountered statements that
foldr is more important than foldl, e.g. in this post on the list:
http://www.haskell.org/pipermail/haskell-cafe/2012-May/101338.html
I want to know are such statements correct and, if so, why? I am aware that foldl' can in some
circumstances operate in constant space, while foldr can operate on infinite lists if the folding
function is lazy in the second parameter. Is there more to this subject? Properties that I
mentioned are more of technical nature, not theoretical ones. Are there any significant
theoretical advantages of foldr? I read Bird's and Wadler's "Introduction to functional
programming" and it seems to me that foldl and foldr have the same properties and in many cases
are interchangeable.
Greets,
Janek
More information about the Haskell-Cafe
mailing list