Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] lazy lists
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] lazy lists
Michael Vanier <> writes:

> What's the best way to write a lazy list data type in ocaml?  I've been
> playing around with this datatype (from an old mailing list posting):
> type 'a stream =
>   Nil
> | Cons of 'a Lazy.t * 'a stream Lazy.t
> but I can't figure out how to write a "stream_cons" function.  

you mean :

let stream_cons x y =
  lazy Cons (x, y)

> Also, it
> appears that the Lazy.t data type uses references; why is this?

Because it is the standard way of doing it with a non lazy
Rémi Vanicat
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: