-
-
Save tomjack/223d4f377d4b3e7d6dab to your computer and use it in GitHub Desktop.
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 btwoc* [sofar n] | |
(if (zero? n) | |
(let [first-char (first sofar)] | |
(if (or (and first-char (bit-test (int first-char) 7)) | |
(empty? sofar)) | |
(conj sofar (char 0)) | |
sofar)) | |
(recur (conj sofar (char (bit-and n 0xFF))) | |
(bit-shift-right n 8)))) | |
(defn btwoc [n] | |
(apply str (btwoc* '() n))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment