Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Florian Hars <hars@bik-gmbh.de>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] reading/writing binary data
Date: Tue, 21 Nov 2006 20:57:02 +0100	[thread overview]
Message-ID: <45635A0E.5030308@bik-gmbh.de> (raw)
In-Reply-To: <200611211410.52422.jon@ffconsultancy.com>

Jon Harrop schrieb:
> I want to see those HOFs:
> 
>   let output_binary_int_little_endian ch n =
>     List.iter (fun i -> output_byte ch ((n lsr i) land 0xff)) [0; 8; 16; 24];;

Why not go the whole way?

let little_endian = [0; 8; 16; 24]
let middle_endian = [16; 24; 0; 8]
let big_endian = [24; 16; 8; 0]

let output_binary_int endianness ch n =
   List.iter (fun i -> output_byte ch ((n lsr i) land 0xff)) endianness

Now all we need is a PDP-11 port...

Yours, Florian.



      reply	other threads:[~2006-11-21 19:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 11:34 Dário Abdulrehman
2006-11-21 13:15 ` [Caml-list] " Olivier Andrieu
2006-11-21 13:29   ` Dário Abdulrehman
2006-11-21 13:56     ` Dmitry Bely
2006-11-21 14:10       ` Jon Harrop
2006-11-21 19:57         ` Florian Hars [this message]

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=45635A0E.5030308@bik-gmbh.de \
    --to=hars@bik-gmbh.de \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /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