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 LAA22486; Thu, 29 Jul 2004 11:26:02 +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 LAA11080 for ; Thu, 29 Jul 2004 11:26:01 +0200 (MET DST) Received: from mta1.cl.cam.ac.uk (mta1.cl.cam.ac.uk [128.232.0.15]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6T9Q0SH026437 for ; Thu, 29 Jul 2004 11:26:00 +0200 Received: from zonule.cl.cam.ac.uk ([128.232.9.23] helo=cl.cam.ac.uk ident=[9vthZnOZ4hl66UhcxTQIVyVpbwzFqzSj]) by mta1.cl.cam.ac.uk with esmtp (Exim 3.092 #1) id 1Bq7Aj-0001vn-00; Thu, 29 Jul 2004 10:25:57 +0100 X-Mailer: exmh version 2.6.3-CL 04/04/2003 with nmh-1.0.4 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: cslists/caml To: Daniel Andor cc: Ocaml Subject: Re: [Caml-list] looping recursion In-reply-to: Your message of "Thu, 29 Jul 2004 10:13:12 BST." <200407291013.12467.da209@cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Date: Thu, 29 Jul 2004 10:25:57 +0100 From: Keith Wansbrough Message-Id: X-Miltered: at concorde with ID 4108C2A8.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 recursion:01 lemme:01 ocamlc:01 usr:01 vanilla:01 usr:01 ocamlopt:01 0.81:01 vanilla:01 implemented:01 compiler:01 ocaml:01 lazy:02 library:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Lemme try it out (10^6 elements): > > ocamlc: > rev rev_map version: > 2 WALL ( 1.19 usr + 0.02 sys = 1.21 CPU) > vanilla map: > 7 WALL ( 6.50 usr + 0.09 sys = 6.59 CPU) > > ocamlopt: > rev rev_map version: > 1 WALL ( 0.81 usr + 0.03 sys = 0.84 CPU) > vanilla map: > 2 WALL ( 2.45 usr + 0.02 sys = 2.47 CPU) OK, so why is List.map in the OCaml standard library implemented the vanilla way rather than the rev rev_map way? If it's such a big win, it seems foolish to have a broken implementation for such a crucial function. (BTW, if you want efficient (and pure) mapping and filtering over long streams, you should consider using lazy lists. A good compiler (like GHC) will do the deforestation optimisation, so the list is never even allocated[1].) [1] unless you make use of persistence, of course. --KW 8-) ------------------- 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