Created
June 27, 2011 22:27
-
-
Save swannodette/1050007 to your computer and use it in GitHub Desktop.
byte-seq.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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