From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA16899; Thu, 29 Apr 2004 14:30:08 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA16892 for ; Thu, 29 Apr 2004 14:30:06 +0200 (MET DST) Received: from eris.rz.uni-saarland.de (eris.rz.uni-saarland.de [134.96.7.8]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3TCU5YM032318 for ; Thu, 29 Apr 2004 14:30:05 +0200 Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.254.254]) by eris.rz.uni-saarland.de (8.12.10/8.12.10) with ESMTP id i3TCTePX31856837 for ; Thu, 29 Apr 2004 14:30:04 +0200 (CST) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.12.11/2003091100) with ESMTP id i3TC5htc009386 for ; Thu, 29 Apr 2004 14:05:43 +0200 (CEST) Received: from ps.uni-sb.de (grizzly.ps.uni-sb.de [134.96.186.68]) by mail.cs.uni-sb.de (8.12.11/2004041400) with ESMTP id i3TC5g04021418 for ; Thu, 29 Apr 2004 14:05:42 +0200 (CEST) X-Authentication-Warning: email: Host grizzly.ps.uni-sb.de [134.96.186.68] claimed to be ps.uni-sb.de Received: from ps.uni-sb.de (groove.ps.uni-sb.de [134.96.186.172]) by ps.uni-sb.de (8.12.10/8.12.10) with ESMTP id i3TC5edQ018873; Thu, 29 Apr 2004 14:05:40 +0200 Message-ID: <4090EF94.6060109@ps.uni-sb.de> Date: Thu, 29 Apr 2004 14:05:40 +0200 From: Andreas Rossberg User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list Subject: Re: [Caml-list] [ANN] The Missing Library References: <20040428151818.GC1310@excelhustler.com> <1083169714.9537.1102.camel@pelican.wigram> <200404281942.05371.jdh30@cam.ac.uk> <1083200626.9537.1199.camel@pelican.wigram> In-Reply-To: <1083200626.9537.1199.camel@pelican.wigram> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by AntiVir Milter 1.0.6; AVE 6.25.0.2; VDF 6.25.0.38 X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; rossberg:01 rossberg:01 uni-sb:01 caml-list:01 monadic:01 admittedly:01 delivers:99 lazily:01 uni-sb:01 computed:01 ocaml:01 ocaml:01 lazy:02 lazy:02 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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