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
[ 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...>
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 ;

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


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