Differences Between `Foldl` and `Foldr`

(blog.haskell.org)

22 points | by signa11 4 days ago

1 comments

  • s-zeng 37 minutes ago
    A neat fact about foldr on lists, unlike foldl, is that it actually passes control flow entirely to the accumulating function on each fold step. That means you can use foldr to implement arbitrary traversals of lists, including foldl' or list traversals that exit early. See https://github.com/quchen/articles/blob/master/useful_techni...