[Haskell-cafe] Suggestions for improvement

wren ng thornton wren at freegeek.org
Sun Oct 3 20:03:22 EDT 2010

On 10/3/10 5:52 PM, Victor Nazarov wrote:
> I suggest to pay more attention to haskell's standard library.
> "allButLast" is called "init" in Data.List module.
> Second, do not use explicit recursion. You can capture recursion using
> some high-order function like map, filter, foldr and so on:
> lastToTheLength xs = map f xs
>    where f = const . last $ xs

And just to play a little Haskell golf:

     lastToTheLength = ap (flip map) (const . last)

Live well,

More information about the Haskell-Cafe mailing list