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 CAA04509; Thu, 29 Apr 2004 02:54:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 CAA04170 for ; Thu, 29 Apr 2004 02:54:24 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3T0sLYM028946 for ; Thu, 29 Apr 2004 02:54:22 +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 i3T0sAZq071000; Thu, 29 Apr 2004 10:24:11 +0930 (CST) Subject: Re: [Caml-list] [ANN] The Missing Library From: skaller Reply-To: skaller@users.sourceforge.net To: John Goerzen Cc: Jon Harrop , caml-list In-Reply-To: <20040428180243.GA4404@excelhustler.com> References: <200404280613.19547.jdh30@cam.ac.uk> <1083141467.9537.845.camel@pelican.wigram> <200404281018.14913.jdh30@cam.ac.uk> <1083151482.9537.904.camel@pelican.wigram> <20040428151818.GC1310@excelhustler.com> <1083169714.9537.1102.camel@pelican.wigram> <20040428180243.GA4404@excelhustler.com> Content-Type: text/plain Message-Id: <1083200049.9537.1189.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 29 Apr 2004 10:54:09 +1000 Content-Transfer-Encoding: 7bit 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; caml-list:01 sourceforge:01 2004:99 2004:99 ignores:01 inverted:01 implemented:01 bug:01 9660:01 glebe:01 ocaml:01 nsw:01 snail:02 checkout:02 2037:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 2004-04-29 at 04:02, John Goerzen wrote: > On Thu, Apr 29, 2004 at 02:28:35AM +1000, skaller wrote: > > On Thu, 2004-04-29 at 01:18, John Goerzen wrote: > > > > In Ocaml you can add state of course. But it's a mess. > > > > > > I don't find it all that problematic. > > > > Compare: > > > > let count = ref 0 in > > List.iter > > (fun x -> > > if !start = 0 then > > (start := 1; print "["; print x; ) > > else (print ";"; print x) > > ) > > lst; > > if (!start <> 0) then print "]" > > > > and please don't tell me that isn't a total mess compared with > > Of course, your example ignores nicer features available for > this sort of thing. Indeed. If I may be so bold to observe .. you've control inverted. You're now driving the iteration. You've got rid of the HOF List.iter and implemented your own special one. The point of the code I displayed was that it control inverts *without* getting rid of the driver loop. Also .. a small bug in your translation: it prints "[]" for an empty list. The original prints "". -- 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