Created
September 27, 2012 18:34
-
-
Save shaunxcode/3795605 to your computer and use it in GitHub Desktop.
query info for datomic
This file contains hidden or 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
;;takes datomic query and turns it into map so it may be interrogated | |
(defn query-info [query] | |
(let [parts (partition-by keyword? query) | |
is-kw #(keyword? (first %))] | |
(zipmap | |
(map first (filter is-kw parts)) | |
(remove is-kw parts)))) | |
;;eg | |
((query-info '[:find ?x ?y ?z :in $ ?d :where [?x :some/thing ?y] [?x :some/otherthing ?z]]) :find) | |
;;yields | |
(?x ?y ?z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment