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 XAA00779; Wed, 28 Jul 2004 23:22:06 +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 XAA00371 for ; Wed, 28 Jul 2004 23:22:04 +0200 (MET DST) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6SLM2SH012818 for ; Wed, 28 Jul 2004 23:22:03 +0200 Received: (qmail 21498 invoked from network); 28 Jul 2004 21:22:01 -0000 Received: from shell2.speakeasy.net ([69.17.110.71]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 28 Jul 2004 21:22:01 -0000 Date: Wed, 28 Jul 2004 14:22:01 -0700 (PDT) From: brogoff To: Ocaml Subject: Re: [Caml-list] looping recursion In-Reply-To: <200407282040.40600.jon@jdh30.plus.com> Message-ID: References: <16646.64470.304530.264731@soggy.deldotd.com> <4107544C.4040502@baretta.com> <200407282040.40600.jon@jdh30.plus.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 410818FA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; brogoff:01 brogoff:01 caml-list:01 recursion:01 2004:99 38,:01 000,:01 ocamlopt:01 caml-list:01 extlib:01 seattle:99 damned:01 recursion:01 ocaml:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 28 Jul 2004, Jon Harrop wrote: > On Wednesday 28 July 2004 17:38, brogoff wrote: > > > brogoff wrote: > > > > Sometimes lists are best. If lists are OK for 100, 1_000, or 10_000 > > > > items, why not 100_000 or 1_000_000? Map and friends shouldn't blow > > > > stack. > > Creating an int list with 1,000,000 elements and applying List.map using > ocamlopt works fine here, and took a meagre 3.6 secs. > > If you must use bytecode for this then just increase the stack size limit, for > example to 8Mb: > > export OCAMLRUNPARAM='l=8M' > > Then it runs fine, in 10.7 secs here. Wow, that's quite fast... :-) I'm going to guess that you don't have much OCaml code running at a customer site. Yes, I'm aware that stack size can be reset. Oh joy. I guess we don't need tail call elimination at all then? > > Well, I'm still on the caml-list, so of course it isn't *that* bad. Also, > > as I said, if you need a tail recursive map over built in lists, you have > > at least two options. Unfortunately, my preference is to use Obj, which IMO > > points to a deficiency in the core language. > > No! That points to a severe deficiency in your programming style. OCaml has > been developed and used by a great many very clever people, and me. If you're > doing things like that then you should immediately stop and think what you > might be doing wrong. I guess all of the authors of ExtLib, who, last time I checked, used a set_cdr approach, are also tyros compared to you? > Perhaps you picked the bad style up at a Seattle OCaml user group meeting? Very classy. :-( > What's wrong with List.rev_map, List.rev (List.rev_map ...), increasing the > size of the VM's stack, using native code or even writing your own, > tail-recursive map? I'm pretty damned well aware that I can reverse a rev mapped list. Does it occur to you that that is not efficient? Have you tried comparing the run times of this versus set_cdr version? Where were you when the "tail recursion modulo cons" discussion came up? Do you understand that optimization? Here's a pointer for you http://caml.inria.fr/archives/200306/msg00254.html By my measurements, even for small lists, the set_cdr version was as fast (a little faster even) than List.map, and it had the nice property of not failing with huge lists. -- Brian ------------------- 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