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 GAA27065; Sun, 4 May 2003 06:05:55 +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 GAA26798 for ; Sun, 4 May 2003 06:05:54 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from easystreet01.easystreet.com (smtp.easystreet.com [206.26.36.40]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4445qT04885 for ; Sun, 4 May 2003 06:05:53 +0200 (MET DST) Received: from PublicPropertySoftware.com (dial-206-102-3-236.dial.easystreet.com [206.102.3.236]) by easystreet01.easystreet.com (Postfix) with ESMTP id 2330484531E for ; Sat, 3 May 2003 21:05:50 -0700 (PDT) Message-ID: <3EB4922A.A69C2038@PublicPropertySoftware.com> Date: Sat, 03 May 2003 21:08:10 -0700 From: alc@PublicPropertySoftware.com X-Mailer: Mozilla 4.79 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Cc: "caml Mailing List'" Subject: Re: [Caml-list] Efficiency of 'a list References: <03ea01c311a3$ee573560$0200a8c0@gateway> <87r87fv4ya.fsf@cs.uga.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; caml-list:01 hash:01 recursively:01 ocaml:01 tree:02 wrote:03 array:04 efficiency:05 maybe:06 lists:91 looping:08 modification:08 iteration:09 i've:09 elements:12 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk cashin@cs.uga.edu wrote: > > Whenever you've got a situation where access is always via > straightforward iteration and modification is at the beginning or end > of a sequence, it doesn't make sense to use a hash table or even a > tree. When you don't know the size ahead of time, it doesn't make > sense to use an array either. A list is just the right thing in that > case. > I've done a little timing of things, and according to my results: If you care about efficiency and use OCaml, you should use lists fairly often, ie if you are always looping and accessing the elements in order. OCaml can iterate through a list (recursively) about twice as fast as it can iterate through an array. It can iterate through a list about as fast as or maybe even a little faster than C or C++ can iterate through an array. Al ------------------- 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