
3 Oct
2010
3 Oct
'10
8:03 p.m.
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, ~wren