[Haskell-cafe] Re: Suggestions for improvement
raghu at mri.ernet.in
Mon Oct 4 00:56:19 EDT 2010
At 2010-10-04T01:52:05+04:00, Victor Nazarov wrote:
> I suggest to pay more attention to haskell's standard library.
> "allButLast" is called "init" in Data.List module.
Thanks for that. I should keep printouts of the Prelude handy.
> 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 last, your type signatures are too restrictive. You can apply your
> functions to arbitrary lists.
> lastToTheLength :: [a] -> [a]
> Standard library knowledge is very helpful in producing short and
> clear definitions.
> blowup = concat . zipWith replicate [1..]
That looks neat! Many thanks for the detailed remarks.
N. Raghavendra <raghu at mri.ernet.in> | http://www.retrotexts.net/
Harish-Chandra Research Institute | http://www.mri.ernet.in/
See message headers for contact and OpenPGP information.
More information about the Haskell-Cafe