Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created June 27, 2011 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/1050007 to your computer and use it in GitHub Desktop.
Save swannodette/1050007 to your computer and use it in GitHub Desktop.
byte-seq.clj
(defn byte-seq [b]
(loop [n 0 b b s []]
(if (< n 8)
(recur (inc n) (bit-shift-right b 1) (conj s (bit-and b 1)))
(reverse s))))
(comment
(byte-seq -122)
(take 4 (byte-seq -122))
(drop 4 (byte-seq -122))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment