Re: [Haskell-cafe] reverse with foldl

2007-09-21 Thread Rodrigo Queiro
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 <[EMAIL

Re: [Haskell-cafe] reverse with foldl

2007-09-20 Thread Miguel Mitrofanov
> reverse = foldl (\x -> \xs -> xs:x) [] Doesn't typecheck. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] reverse with foldl

2007-09-20 Thread PR Stanley
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 ___