Hi Vlad,
On Thu, Nov 20, 2008 at 5:36 PM, prhlava <[EMAIL PROTECTED]> wrote:
>
> Hello Graham,
>
>> Bonus question for the bored reader: write a function,
>> (byte-array-maker N), that takes a width N, and returns a function
>> that takes an Integer as input and returns an N-width byte array
>> c
Hello Jeffrey,
> Code is located at:
> http://github.com/jbester/cljext/tree/master/cljext%2Fbinpack.clj
Thanks for the link, more food for study on how to write a generic
library...
Basically, I am scheme/lisp noob, learning it in my spare time, the
progress is slow but rewarding...
Few obs
Hello Graham,
> Bonus question for the bored reader: write a function,
> (byte-array-maker N), that takes a width N, and returns a function
> that takes an Integer as input and returns an N-width byte array
> containing the Integer in big-endian order. E.g.
>
> ((byte-array-maker 4) 652187261)
>
Not sure if this will help with what you are working on. I ran across
a similar problem last week and ended up writing a generic library
that converts various sizes of integers to big or little endian byte
arrays and then back again.
Code is located at:
http://github.com/jbester/cljext/tree/mas
Hi,
> Dealing with byte-arrays, you will want to use the write-method that
> takes an array, not the one that takes a string.
>
> Constructing the array is a bit tricky:
>
> ; Define your int
> (def pix 652187261)
>
> ; Define your array, typed as array of char
> (def payload
> (into-array Chara
In general, Writers are for character data and OutputStreams are for
binary data. If possible, create a FileOutputStream like this:
(ns my.ns
(:import (java.io FileOutputStream)))
(def ofile (FileOutputStream. "/some/file/somewhere"))
and use one of the write methods of FileOutputStream.
--~-
On Nov 19, 5:51 pm, prhlava <[EMAIL PROTECTED]> wrote:
> (. ofile write (str
> (char (bit-shift-right pix 16))
> (char (bit-shift-right pix 8))
> (char pix)))
>