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 HAA30905; Wed, 28 Jul 2004 07:54:30 +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 HAA30848 for ; Wed, 28 Jul 2004 07:54:28 +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 i6S5sQSH026674 for ; Wed, 28 Jul 2004 07:54:27 +0200 Received: (qmail 9297 invoked from network); 28 Jul 2004 05:54:25 -0000 Received: from shell1.speakeasy.net ([69.17.110.70]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 28 Jul 2004 05:54:25 -0000 Date: Tue, 27 Jul 2004 22:54:25 -0700 (PDT) From: brogoff To: briand@aracnet.com cc: Brian Hurt , John Prevost , Ocaml Mailing List Subject: Re: [Caml-list] looping recursion In-Reply-To: <16647.5177.849829.421587@soggy.deldotd.com> Message-ID: References: <16646.64470.304530.264731@soggy.deldotd.com> <16647.5177.849829.421587@soggy.deldotd.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 41073F92.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 tweaks:01 okasaki's:01 suboptimal:01 non-obvious:01 extlib:01 breath:01 inclined:01 000,:01 implementors:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 27 Jul 2004 briand@aracnet.com wrote: > >>>>> "Brian" == Brian Hurt writes: > it really is. > although I'd actually like it to be an array. > it's the classic situation, read whole file - iterate on elements. > easy to do in a list since I don't need to know the size. > > some minor tweaks and I can include the size in a data file and just > fill an array directly. > > however, my larger point is the fact that the "standard" map blows up > like that. as a long time scheme user I just find that plain weird. > Now Everybody else seems to think I'm weird because I think that's > weird ;-) > > Brian> Very long lists are a sign that you're using the wrong data > Brian> structure. > > I'm not sure I understand that. I've heard the argument plenty of times, and I'm familiar with all of the common data structures (and the uncommon ones in Okasaki's book), and I don't buy that argument either. It's a limitation of the current OCaml list library functions and the current implementation of OCaml. You can easily fix it yourself by writing mapand friends to be tail recursive in the straightforward way (suboptimal efficiency, but better than failing) or the non-obvious way using Obj to make the equivalent of set-cdr! (what ExtLib does) or wait until the implementors decide to fix this by adding a language feature and reimplementing List. Don't hold your breath for that last option. > Part of the problem is that powerful computers make for lazy > programmers :-) It's just so easy to read the 10^6 elements into a > list and then just keep map'ing them to the final value when it only > takes seconds to do :-) If it took 2 minutes I'd be more inclined to > think about the problem. 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. -- 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