Skip to content

Instantly share code, notes, and snippets.

@shaunxcode
Created September 27, 2012 18:34
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 shaunxcode/3795605 to your computer and use it in GitHub Desktop.
Save shaunxcode/3795605 to your computer and use it in GitHub Desktop.
query info for datomic
;;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