From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA23355; Tue, 22 Oct 2002 17:01:38 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA23506 for ; Tue, 22 Oct 2002 17:01:36 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from climbxp ([159.226.149.121]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g9MF1X517085 for ; Tue, 22 Oct 2002 17:01:34 +0200 (MET DST) Message-Id: <200210221501.g9MF1X517085@concorde.inria.fr> From: "climb" To: "caml-list@inria.fr" X-mailer: Foxmail 4.2 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit Date: Tue, 22 Oct 2002 23:1:34 +0800 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Dear caml-list i want to build a function f: char array -> string which just make a char array into a string. But i dont want to do like this let f ary= let str = String.create(Array.length ary) in for i=0 to (Array.length ary)-1 do str.[i]<- ary.(i) done ; str;; since if do like this, i have to make a new string of extra memory, what i want to generate is a string that share the same memory with the char array. The reason is that i should deal with 'a array , however when it is a char array, i want to seen it as a string in order to do some regular matching which can only take on strings. But my problem is that the char arrays are very long(1M each or longer) ,so it is expensive to make a string copy of it. In o'relly 's book, it says Character strings can be considered a special case of vectors of characters. Then what shall i do ? or my function above is efficient enough ? or i cannt do the shareing because as the book says that one char in string is a byte . ? Best regards Yours climb onlyclimb@163.com 2002-10-22 ------------------- 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