From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 065517EE51 for ; Thu, 9 May 2013 15:32:43 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of tom.j.ridge@googlemail.com) identity=pra; client-ip=209.85.160.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of tom.j.ridge@googlemail.com designates 209.85.160.54 as permitted sender) identity=mailfrom; client-ip=209.85.160.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pb0-f54.google.com) identity=helo; client-ip=209.85.160.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="postmaster@mail-pb0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AggCAEaki1HRVaA2jWdsb2JhbABShjMBvgQIFg4BAQEBBwsLCRIGJIJNGQEBOBAVXRIBBQEiiAwBAw+gO4p8hD8BBYRKChknDYgKBpMEly+PUBYpgV2CWTs X-IPAS-Result: AggCAEaki1HRVaA2jWdsb2JhbABShjMBvgQIFg4BAQEBBwsLCRIGJIJNGQEBOBAVXRIBBQEiiAwBAw+gO4p8hD8BBYRKChknDYgKBpMEly+PUBYpgV2CWTs X-IronPort-AV: E=Sophos;i="4.87,641,1363129200"; d="scan'208";a="16639789" Received: from mail-pb0-f54.google.com ([209.85.160.54]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 May 2013 15:32:42 +0200 Received: by mail-pb0-f54.google.com with SMTP id rr4so1994557pbb.13 for ; Thu, 09 May 2013 06:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:mime-version:sender:from:date:x-google-sender-auth :message-id:subject:to:content-type; bh=iNZWo4JGYm/+sq94QJLqsom6+2EXvYENYU0Mu0zV6o0=; b=BZluRfiwNfG3UbRXCLg0hM/WEjCoH8VYUvT6f1RYZHCrq5pBfk8WbzgXkcRvZf7Fzj aDnC8Dp6y9VcP2n/uwC58SnBlIbu4NUdfVqHiwiJkpU+mN/r/NprPup4fwes5qcMVnju wcqV5eYhTUPJMvfGcc0PSVCP17eno5V8Bep5JUTyBOH9zWwDyXs4oN0mklaVplubX/a2 AQW7L9+16sCzN+2Qv5cYcQpwbJekAiebR4ER6TioUuTVdm6oNS8o7FlpU3m5vOrFffD2 BXYWv1n6Gd7NaJHqRnZ/sOqYTtu821ILRnuiiJ5YlhpYIsk/tgZ6SOM1ysTSXX3FEgjW dJhA== X-Received: by 10.66.26.166 with SMTP id m6mr13259119pag.68.1368106361005; Thu, 09 May 2013 06:32:41 -0700 (PDT) MIME-Version: 1.0 Sender: tom.j.ridge@googlemail.com Received: by 10.70.52.66 with HTTP; Thu, 9 May 2013 06:32:20 -0700 (PDT) From: Tom Ridge Date: Thu, 9 May 2013 14:32:20 +0100 X-Google-Sender-Auth: kHMNrQRPJoqH9c9xjSJOgO4wK28 Message-ID: To: caml-list Content-Type: text/plain; charset=ISO-8859-1 Subject: [Caml-list] String, Array, Bigarray.char 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