English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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, 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