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: skaller <skaller@u...>
Subject: Re: [Caml-list] [ANN] The Missing Library
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