Skip to content

Instantly share code, notes, and snippets.

@malloc47
Last active May 24, 2016 01:19
Show Gist options
  • Save malloc47/35a30b4a084c5803833032d1996cbc5f to your computer and use it in GitHub Desktop.
Save malloc47/35a30b4a084c5803833032d1996cbc5f to your computer and use it in GitHub Desktop.
(ns bit)
(defn printb
[n]
(Integer/toBinaryString n))
(defn count-1s
[n]
(->> n printb (filter #{\1}) count))
# bit-and bit-or bit-xor bit-not bit-flip bit-set bit-shift-right bit-shift-left bit-and-not bit-clear bit-test unsigned-bit-shift-right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment