Version française
Home     About     Download     Resources     Contact us    
Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: climb <onlyclimb@1...>
Subject:
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