Created
December 17, 2013 19:21
-
-
Save arohner/8010983 to your computer and use it in GitHub Desktop.
core.typed + keys
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
(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