[Haskell-cafe] infinite lists
Matthias Fischmann
fis at wiwi.hu-berlin.de
Tue Mar 27 08:07:06 EDT 2007
On Tue, Mar 27, 2007 at 08:02:18PM +1000, Matthew Brecknell wrote:
> To: Matthias Fischmann <fis at wiwi.hu-berlin.de>
> Cc: haskell-cafe at haskell.org
> From: Matthew Brecknell <haskell at brecknell.org>
> Date: Tue, 27 Mar 2007 20:02:18 +1000
> Subject: Re: [Haskell-cafe] infinite lists
>
> Matthias Fischmann:
> > g = do
> > n <- randomRIO (0,5)
> > let l = replicate n '*'
> > i | null l = []
> > | otherwise = join $ repeat l
> > print (take 12 i)
>
> If you had written (cycle l) instead of (join $ repeat l), you would
> have figured it out much quicker. :-)
>
> Prelude> cycle []
> *** Exception: Prelude.cycle: empty list
good point. and now i am learning a new word. eek! :)
thanks -
m
More information about the Haskell-Cafe
mailing list