Created
November 1, 2015 20:38
-
-
Save taylorSando/1d12038fd77fa6f71bd9 to your computer and use it in GitHub Desktop.
A simple selector
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 is-predicate-keyword? [k] | |
(= (last (name k)) (last "?") )) | |
(reduce | |
(fn [acc [k v]] | |
(if (is-predicate-keyword? k) | |
(if (true? v) | |
(conj acc (apply str (butlast (name k)))) | |
acc) | |
acc)) | |
[] | |
{:x :value | |
:x? true | |
:y? false | |
:z true}) | |
;; should output ["x"] | |
(is-predicate-keyword? :hello) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment