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 HAA19607; Thu, 29 Apr 2004 07:38:36 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA19592 for ; Thu, 29 Apr 2004 07:38:35 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3T5cWjq031469 for ; Thu, 29 Apr 2004 07:38:33 +0200 Received: from [192.168.1.200] (ppp114-169.lns1.syd3.internode.on.net [150.101.114.169]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3T5cRZq096239; Thu, 29 Apr 2004 15:08:28 +0930 (CST) Subject: Re: [Caml-list] [ANN] The Missing Library From: skaller Reply-To: skaller@users.sourceforge.net To: Jon Harrop Cc: caml-list In-Reply-To: <200404290604.13189.jdh30@cam.ac.uk> References: <200404290256.24399.jdh30@cam.ac.uk> <1083207649.9537.1250.camel@pelican.wigram> <200404290604.13189.jdh30@cam.ac.uk> Content-Type: text/plain Message-Id: <1083217105.9537.1295.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 29 Apr 2004 15:38:26 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 2004:99 supplier:99 supplier:99 implemented:01 9660:01 glebe:01 mutable:01 mutable:01 rec:01 nsw:01 snail:02 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 2004-04-29 at 15:04, Jon Harrop wrote: > On Thursday 29 April 2004 4:00 am, skaller wrote: > > On Thu, 2004-04-29 at 11:56, Jon Harrop wrote: > > > Can you give me a simple example where you are forced to use mutable > > > state? > > ... > > The inverse is a supplier of list elements: > > > > let make_supplier lst = > > let lst = ref lst in > > let get () = function > > > > | h :: t -> lst :=t; h > > | [] -> raise Not_found > > But can't this be implemented without mutable state as: > > let make_supplier lst = > let rec get lst () = match lst with [] -> raise Not_found | h::t -> (h, fun > () -> get t ()) in > get lst > > so it returns the next element and a function to "supply" the rest. CPS transform? > I don't know. I just brush my hands over the keyboard and programs come > out. :-) teach me your technique! When I do that, i just get bugs leaping out! -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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