Last active
August 29, 2015 13:56
-
-
Save viperscape/9134465 to your computer and use it in GitHub Desktop.
returns map of which bits where flagged
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- bits-lit [b] | |
"cerates seq of bits that are flagged" | |
(map #(bit-and b (bit-shift-left 1 %)) (range 8))) | |
(bits-lit 23) ;;(1 2 4 0 16 0 0 0) | |
(map pos? (bits-lit 23)) ;; (true true true false true false false false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment