Skip to content

Instantly share code, notes, and snippets.

@dmt
Created July 21, 2011 10:03
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 dmt/1096897 to your computer and use it in GitHub Desktop.
Save dmt/1096897 to your computer and use it in GitHub Desktop.
functions as map keys
(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