caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] String, Array, Bigarray.char
@ 2013-05-09 13:32 Tom Ridge
  2013-05-09 13:44 ` Anil Madhavapeddy
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Tom Ridge @ 2013-05-09 13:32 UTC (permalink / raw)
  To: caml-list

Dear caml-list,

Quick question: I am working a lot with arrays of byte, which at
various points I want to view as strings, and at various points I want
to view as arrays. The exact types involved should be discernible from
the code below.

I have some conversion functions e.g.:

  type myfusebuffer = (char, Bigarray.int8_unsigned_elt,
Bigarray.c_layout) Bigarray.Array1.t

  module A = Bigarray.Array1

  (* convenience only; don't use in production code *)
  let array_of_string bs = (
    let arr = (Array.init (String.length bs) (String.get bs)) in
    let contents = A.of_array Bigarray.char Bigarray.c_layout arr in
    contents)
  let (_:string -> myfusebuffer) = array_of_string

This presumably takes O(n) time (where n is the length of the string
bs). My question is: is there functionality to move values between
these types at cost O(1)? Basically, I'm hoping that String is
implemented as A.of_array Bigarray.char Bigarray.c_layout or
similar...

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-05-10 23:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09 13:32 [Caml-list] String, Array, Bigarray.char Tom Ridge
2013-05-09 13:44 ` Anil Madhavapeddy
2013-05-09 14:07   ` Tom Ridge
2013-05-09 14:14     ` Tom Ridge
2013-05-09 14:21       ` Anil Madhavapeddy
2013-05-09 14:30         ` Tom Ridge
2013-05-09 16:29         ` ygrek
2013-05-09 14:29       ` Markus Mottl
2013-05-09 14:25 ` Markus Mottl
2013-05-10 23:42 ` Goswin von Brederlow

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).