foldr :: (a -> b -> b) -> b -> [a] -> b foldr f u [] = u foldr f u (x:xs) = f x (foldr f u xs) foldl :: (a -> b -> a) -> a -> [b] -> a foldl f a [] = a foldl f a (x:xs) = foldl f (f a x) xs