[Haskell-cafe] reverse with foldl

Rodrigo Queiro overdrigzed at gmail.com
Fri Sep 21 10:17:41 EDT 2007


Prelude> :t foldl (\x -> \xs -> xs:x) []
foldl (\x -> \xs -> xs:x) [] :: [b] -> [b]

Strange choice of names, though, since x is a list, and xs is an
element. I would have gone for:
foldl (\xs x -> x:xs) []
although the library opts for:
foldl (flip (:)) []

On 21/09/2007, Miguel Mitrofanov <miguelimo38 at yandex.ru> wrote:
> > reverse = foldl (\x -> \xs -> xs:x) []
>
> Doesn't typecheck.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list