I stumbled across Timothy Baldridge's excellent video 
<http://www.youtube.com/watch?v=HHZ8iqswiCw>explaining how to incorporate 
data sources into core.logic.  It reinvigorated my interest in using 
core.logic to query SQL RDBMS.  I'm stumbling on a pretty simple thing, I 
think.  I've got a table that has three columns, a single primary key 
column and two value columns.  Using the pattern Tim outlines in his video, 
I've got a relation function that takes three parameters, one for each 
column and I'm trying to work through the case where the primary key is 
ground and the value columns are lvars.  This translates to a query of the 
form SELECT v1, v2 FROM t WHERE pkey=?.  Of course, this returns two values 
that must be unified.  That's where I'm stuck.

I know I want to return a substitution map, but I have two lvars to unify.  
How do I merge the two substitution maps?

Sample code:
(defn pkey-v1-v2-o [pkey v1 v2]
  (fn [a]
    (let [pkey (walk a pkey)
          v1 (walk a v1)
          v2(walk a v2)]
      (condp = [(not (lvar? pkey))
                (not (lvar? v1))
                (not (lvar? v2))]
        [true false false ] (to-stream 
                              (let [r (first (query ["SELECT v1, v2 FROM T 
WHERE pkey=?" pkey]))]
                                (some-merge-fn (unify a v1 (:v1 r))
                                               (unify a v2 (:v2 r)))))))))

-- 
-- 
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.

Reply via email to