[Haskell-cafe] are some of these "reverse" algos better than others? is there a quick and dirty way to reveal this fact?

Stuart Cook scook0 at gmail.com
Sun Sep 23 01:11:35 EDT 2007

On 9/23/07, Thomas Hartman <tphyahoo at gmail.com> wrote:
> -- this is the usual implementation right?
> myreverse xs = foldl f [] xs
>   where f accum el = el : accum

This is often written

  reverse = foldl (flip (:)) []

which I quite like, because you can contrast it with

  foldr (:) []

which of course is just a type-restricted version of id.


More information about the Haskell-Cafe mailing list