Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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.

Cheers,

   - Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

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

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners