[Haskell-beginners] More than one way to skin a cat question - repeat

Angus Comber anguscomber at gmail.com
Thu Apr 11 11:43:35 CEST 2013


LYAH beginner on page 55.

What I try to do is see the heading of a section, eg repeat function and
then try to come up with my own version before looking at books
implementation.

Here is my implementation:

repeat' :: a -> [a]
repeat' x = [x] ++ repeat' x

Here is books:

repeat' :: a -> [a]
repeat' x = x:repeat' x

Mine appears to work.  Is mine just as good?  Are there problems with my
way?  Is books way more idiomatic Haskell?

I want to learn the best approaches hence my question.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130411/63ad7d49/attachment.htm>


More information about the Beginners mailing list