[Haskell-beginners] Are these soloutions all valid and a good use of Haskell

Karl Voelker karl at karlv.net
Mon Nov 10 10:16:37 UTC 2014


On Mon, Nov 10, 2014, at 01:50 AM, Roelof Wobben wrote:
> What do you experts think of the different ways ?

2 and 4 are quite similar, and both fine. 3 is not so good: guards
provide weaker guarantees than patterns, and head and tail are partial
functions.

All three implementations have in common that they do their own
recursion. It would be a good exercise to try implementing last as a
fold - in other words, letting the standard library do the recursion for
you.

-Karl


More information about the Beginners mailing list