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] [ANN] The Missing Library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-29 (12:30)
From: Andreas Rossberg <rossberg@p...>
Subject: Re: [Caml-list] [ANN] The Missing Library
skaller wrote:
> Sure like to see a monadic/lazy solution to
> the example using streams ..

Admittedly, I'm too lazy ( :-) ) to give an example right now, but the 
idea behind the lazy solution is very simple: for iteration, your 
collection provides a function that delivers a list of all items. You 
can then iterate over it as you would normally do for lists.

However, the important point is: the list is constructed lazily (in 
OCaml, by using the type I showed in my previous posting, or something 
similar). That is, only when you try to match the next item, i.e. the 
tail of the stream (in OCaml, by forcing it) it is actually computed. 
Thereby, the client takes control over the iteration.

Note that lazy functional languages can often perform optimizations like 
deforestation to avoid actual construction of the intermediate list.


   - Andreas

Andreas Rossberg,

Let's get rid of those possible thingies!  -- TB

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: