Browse thread
[oliver: Re: [Caml-list] Strings as arrays or lists...]
[
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: | Olivier Andrieu <andrieu@i...> |
| Subject: | Re: [oliver: Re: [Caml-list] Strings as arrays or lists...] |
Issac Trotts [Monday 3 March 2003] : > Char arrays take up four times as much space as strings, but there is a > tradeoff > of space versus time. The statement > > let a = Array.make 2000000 ' ';; > > takes no noticable time, but > > let s = String.make 2000000 ' ';; > > takes about 7 seconds to run on my computer. Er ... what are you talking about ? If you're talking about the toplevel, that's completely irrelevant because what takes time then is merely the _printing_ of the value. Strings are printed entirely by the toplevel (not very smart for long strings), whereas only the first values of arrays are printed. String.make and Array.make still do the same thing : allocate some space and fill it with an initial value. But array of chars take up four times as much space and thus it usually takes longer to allocate such a big array. -- Olivier ------------------- 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