Lazy lists - an implementation.

Richard Carlsson <>
Wed Oct 18 14:13:12 CEST 2000

On Wed, 18 Oct 2000, Robert Virding wrote:

> Richard Carlsson <> writes:
> >
> >On Tue, 17 Oct 2000, Sean Hinde wrote:
> >
> >> If we already have a large list and want to generate another I guess
> >> there would there be no benefit of converting this into a lazy_list
> >> first? (would this make a Huge fun?)
> >
> >Not "Huge" - the function "lazy(L)" takes your normal list and embeds it
> >in a small fun (no copying done) which will on demand return the next
> >element. The space usage is comparable to a tuple with a small number of
> >elements.
> Yes, but you would still already have created the original huge list.
> Converting it to a lazy list AFTERWARDS will not gain you anything in
> space, actually it will cost you as you replace a cons cell with a 
> tuple of a few extra elements.  That added to the extra execution cost 
> of first making it lazy and then extracting each cons cell makes it all 
> seem like a big lose.

I'm sorry for being unclear - that was not what I was trying to convey -
only that if you do have a normal list and you *want* to use it as a
stream (for whatever reason) you do not get a big space penalty for it. Of
course, you cannot make an existing huge list vanish by wrapping it in a


Richard Carlsson ()   (This space intentionally left blank.)
E-mail: 	WWW:

More information about the erlang-questions mailing list