Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] scripting ocaml from inside of ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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

let associate = 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.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: