[Haskell-beginners] Circular Linked Lists

John Hartnup john.hartnup at gmail.com
Tue Feb 3 09:52:33 EST 2009

2009/2/3 Brent Yorgey <byorgey at seas.upenn.edu>:

>  cycle xs = xs' where xs' = xs ++ xs'
> That sure looks like a cyclic data structure to me! xs' references a
> thunk which computes (xs ++ xs'); this thunk, in turn, references
> xs'. cycle is memory-efficient precisely because it *does* actually
> construct a cyclic data structure.

That's just magnificent!

"There is no way to peace; peace is the way"

More information about the Beginners mailing list