caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Karl Zilles <zilles@1969.ws>
To: Zed Sereg <seregrog@hotmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Operation complexity
Date: Fri, 27 Jun 2003 18:17:19 -0700	[thread overview]
Message-ID: <3EFCEC9F.3070704@1969.ws> (raw)
In-Reply-To: <BAY1-DAV2269QbwyJR50002a294@hotmail.com>

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


  reply	other threads:[~2003-06-28  1:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-27 16:51 [Caml-list] scripting ocaml from inside of ocaml Chris GauthierDickey
2003-06-27 18:00 ` Yamagata Yoriyuki
2003-06-28  0:47   ` [Caml-list] Operation complexity Zed Sereg
2003-06-28  1:17     ` Karl Zilles [this message]
2003-07-01  9:47 ` [Caml-list] scripting ocaml from inside of ocaml Jean-Christophe Filliatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EFCEC9F.3070704@1969.ws \
    --to=zilles@1969.ws \
    --cc=caml-list@inria.fr \
    --cc=seregrog@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).