Browse thread
[Caml-list] Efficiency of 'a list
-
Eray Ozkural
- Mattias Waldau
- Lauri Alanko
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | alc@P... |
| Subject: | Re: [Caml-list] Efficiency of 'a list |
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