Why can you reverse a list with the foldl?
reverse\' :: [a] -> [a] reverse\' xs = foldl (\\acc x-> x : acc) [] xs
But this one gives me a
You can use foldr to reverse a list efficiently (well, most of the time in GHC 7.9—it relies on some compiler optimizations), but it's a little weird:
foldr
reverse xs = foldr (\x k -> \acc -> k (x:acc)) id xs []
I wrote an explanation of how this works on the Haskell Wiki.