Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Efficiency of 'a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ed L Cashin <ecashin@u...>
Subject: Re: [Caml-list] Efficiency of 'a list
alc@PublicPropertySoftware.com writes:

> 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. 

Huh.  I wonder why.  I had a couple of guesses, but I don't know my
way around the ocaml sources, so I couldn't follow up on them (without
spending a bit more time than I have  ;).

-- 
--Ed L Cashin     PGP public key: http://noserose.net/e/pgp/

-------------------
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