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 HAA25397; Wed, 18 Aug 2004 07:11:17 +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 HAA24759 for ; Wed, 18 Aug 2004 07:11:16 +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 i7I5BDmL030087 for ; Wed, 18 Aug 2004 07:11:14 +0200 Received: from [192.168.1.200] (ppp211-206.lns2.syd3.internode.on.net [203.122.211.206]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i7I5B94Y094603; Wed, 18 Aug 2004 14:41:10 +0930 (CST) Subject: Re: [Caml-list] Are map and iter guaranteed to be called in forwards order? From: skaller Reply-To: skaller@users.sourceforge.net To: Jon Harrop Cc: caml-list In-Reply-To: <200408180157.58200.jon@jdh30.plus.com> References: <20040817120053.GA9749@annexia.org> <200408180157.58200.jon@jdh30.plus.com> Content-Type: text/plain Message-Id: <1092805868.29139.1237.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 18 Aug 2004 15:11:09 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4122E4F1.000 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 prevost:01 annotations:01 bug:01 unifying:01 9660:01 glebe:01 caml:01 caml:01 int:01 int:01 nsw:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 2004-08-18 at 10:57, Jon Harrop wrote: > On Tuesday 17 August 2004 15:26, John Prevost wrote: > let index l = > List.rev (snd (List.fold_left (fun (i, l) e -> i+1, (i, e)::l) (0, []) l));; > Ha! Try writing that in Felix (in another mailing-list, of course ;-). Unfair to make that challange and deny the right to a response :) So you get it: its much the same as the Caml version except the type annotations on the arguments are mandatory in Felix: fun index[t] (l:list[t]) => rev (snd ( fold_left (fun (i:int, l: list [t], e: int * t) => i+1, Cons ((i, e),l) ) (0, Empty[t]) l )) ; The actual code above doesn't compile due to a bug, so I'm glad of the example -- thanks! [Looks like I forgot to alpha convert before unifying during overload resolution] However its *should* work: What Caml can do and Felix cannot, is pass a *polymorphic* function as an argument. Caml allows that -- but then you can only use it monomorphically [unless you wrap it in a record]. -- 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