It's common misconception that core.logic is a bunch of macros. The macros are just sugar, there are functions for *everything*.
You can load a stream of "facts" however you please, you should look at `to-stream` which can take any Clojure sequence of data and make it useable from core.logic as a list of facts. Note this is very naive - you'll have to provide indexing yourself if you have a large data set. You might want to take a look at the experimental Datomic integration notes on the core.logic wiki for further guidance. I would look into this approach first and see if this doesn't answer your other questions as well. David On Fri, Jun 21, 2013 at 11:28 AM, Karsten Schmidt <i...@toxi.co.uk> wrote: > 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. > > > -- -- 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.