Hi all, am toying around with the thought of generating core.logic queries dynamically. However, I'm stuck at square one since all the core.logic functions are macros and am not sure how to refer to logic vars within a query generator fn.
E.g. given this list of facts... (def myfacts [[:karsten :spouse :mia] [:fred :spouse :anna] [:mia :name "mia"] [:anna :name "anna"]]) ...I'd like to find the person who's spouse's name is "mia". The SPARQL[1] equivalent for the above would be: SELECT ?p WHERE { ?p :spouse ?s . ?s :name "mia" } In core.logic I can do this equivalently, but have no idea how to generate the lists of `conso`s dynamically: (run* [p] (fresh [s] (conde [(conso p [:spouse s] (myfacts 0))] [(conso p [:spouse s] (myfacts 1))] [(conso p [:spouse s] (myfacts 2))] [(conso p [:spouse s] (myfacts 3))]) (conde [(conso s [:name "mia"] (myfacts 0))] [(conso s [:name "mia"] (myfacts 1))] [(conso s [:name "mia"] (myfacts 2))] [(conso s [:name "mia"] (myfacts 3))]))) ; => (:karsten) a) How would I go about generating such a single `conso` only given a single logic var, var position in the triple and the fact triple itself? b) How can I refer to a logic var in a function outside the lexical scope of `fresh` or `run*`? c) What is the best way to produce and pass a seq of goals for `conde`? Since it is a macro I can't use `apply`... K. [1] http://www.w3.org/TR/sparql11-overview/ -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.