[Haskell-beginners] About repeat function

divyanshu ranjan idivyanshu.ranjan at gmail.com
Fri Jun 24 10:31:26 CEST 2011

As i was going through Learn You a Haskell for Great Good , i came across
following repeat function implementation :
   repeat' ::  x - > [x]
   repeat' x = x : repeat' x
My question is why it produces list in first place. 1:2:3 is not a list but
1:2:3:[] is. How comes haskell know that the things which we are adding will
eventually added to the beginning of  empty list given things are infinite
so you can specify the end which is [] . Then why doing 1:3:4 is not
acceptable ?

Divyanshu Ranjan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110624/8efa47d4/attachment.htm>

More information about the Beginners mailing list