Skip to content

Instantly share code, notes, and snippets.

@chetbox
Created April 30, 2013 16:43
Show Gist options
  • Save chetbox/5489982 to your computer and use it in GitHub Desktop.
Save chetbox/5489982 to your computer and use it in GitHub Desktop.
Encode Clojure vector of floats as byte array
(defn float-vec->byte-array
[v]
(.array (reduce #(.putFloat %1 %2)
(java.nio.ByteBuffer/allocate (* (count v) (/ Float/SIZE 8)))
v)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment