Skip to content

Instantly share code, notes, and snippets.

@arohner
Created December 17, 2013 19:21
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 arohner/8010983 to your computer and use it in GitHub Desktop.
Save arohner/8010983 to your computer and use it in GitHub Desktop.
core.typed + keys
(t/ann flag-keys (t/Map t/Keyword t/Int))
(def flag-keys
{:insensitive Pattern/CASE_INSENSITIVE
:literal Pattern/LITERAL})
(t/ann ^:no-check flags->bitmask [(t/Map t/Keyword Boolean) -> t/Int])
(defn flags->bitmask
[flags]
(->> flags
(filter val)
(keys)
(reduce (t/fn> [val :- t/Int
k :- t/Keyword]
(bit-or val (get flag-keys k 0))) 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment