Created
July 21, 2011 10:03
-
-
Save dmt/1096897 to your computer and use it in GitHub Desktop.
functions as map 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
(def testsToConst { | |
(fn list?) :list, | |
(fn vector?) :vector | |
;; etc... | |
}) | |
;; filter keys in the map by evaluating them for a given col argument, | |
;; take the first result, use that to get the entry from the map. | |
(get testsToConst (first (filter (fn [fun] fun col) (keys testsToConst)))) | |
;; this doesn't work reliably as vectors would be a special case and | |
;; I don't yet know how to escape that when applying. Whatever. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment