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: | Karl Zilles <zilles@1...> |
| Subject: | Re: [Caml-list] Operation complexity |
Zed Sereg wrote: > 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 ledo > v'.(i) <- (request_word v.(i)); > done; > v' > ;; > > val associate : string array -> string array list array = <fun> Hi Zed, Have you looked at Array.map? let associate = Array.map request_word;; > > 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 have trouble believing that associate is your problem. Time to fire up the profiler to find out where that time is coming from? > > 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. Your code looks ok to me. I think your problem is elsewhere. Karl ------------------- 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