[Haskell-cafe] reverse with foldl

PR Stanley prstanley at ntlworld.com
Fri Sep 21 01:55:13 EDT 2007


Hi
reverse = foldl (xs x . x:xs) [] (xs ++ ) = foldl (\ys y -> ys ++ [y]) xs
If I were to define reverse with foldl I would do it this way:
reverse = foldl (\x -> \xs -> xs:x) []

Any idea what the first code frag is suposed to achieve?
Thanks, Paul



More information about the Haskell-Cafe mailing list