Browse thread
[Caml-list] scripting ocaml from inside of ocaml
[
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: | Zed Sereg <seregrog@h...> |
| Subject: | [Caml-list] Operation complexity |
Hello World, I have a obfuscating question, for whih I can found no answer.
I have to handle huge string arrays in a kind of database parsing.
At the end, i have a code of the shape :
let request_word s = ...
val request_word : string -> string array list
let associate v =
let n = Array.length v in
let v' = array.make n (request_word v.(0)) in
for i = 1 to n-1 do
v'.(i) <- (request_word v.(i));
done;
v'
;;
val associate : string array -> string array list array = <fun>
Yeah, it 's obfuscating, but I had no time to find another solution.And this is awfully slow... (In order to know, the computating time of each request separately is around 2 secs. I waited 5 minutes for a call of associate with a 3 elements vector.)
I would like to know if there is a way to do the same thing, without replacing a value in v' at each iteration. Would it really be better to switch the structure from an array to a temporary list, and after, copying the list into an array with Array.of_list.
Thanks
Zed