Dissecting foldl in terms of foldr
2018-01-22
The book ‘Real World Haskell’ provides an implementation of foldl in terms of foldr:
myFoldl:: (b -> a -> b) -> b -> [a] -> b
myFoldl f z xs = foldr step id xs z
where step x g a = g(f a x)
They ask the reader (me) to try to understand the implementation …