From: "climb" <onlyclimb@163.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Date: Tue, 22 Oct 2002 23:1:34 +0800 [thread overview]
Message-ID: <200210221501.g9MF1X517085@concorde.inria.fr> (raw)
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
next reply other threads:[~2002-10-22 15:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-22 15:01 climb [this message]
2002-10-22 16:30 ` [Caml-list] Re: char array vs. string Chris Hecker
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=200210221501.g9MF1X517085@concorde.inria.fr \
--to=onlyclimb@163.com \
--cc=caml-list@inria.fr \
/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