Hi everyone,

I'm trying to get my head around relational progamming those days, with the 
help of core.logic
I'm trying to implement this kind of relation: 

core.logic is aliased as l
core.logic.fd as fd

(defn zip+o [l1 l2 l3]
  (conde
    [(== () l1) (== () l2) (== () l3)]
    [(fresh [fl1 rl1 fl2 rl2 fl3 rl3]
            (l/conso fl1 rl1 l1)
            (l/conso fl2 rl2 l2)
            (l/conso fl3 rl3 l3)
            (fd/in fl1 fl2 fl3 (fd/interval 100))
            (fd/+ fl1 fl2 fl3)
            (zip+o rl1 rl2 rl3))]))


(run* [q]
      (fresh [a b]
             (== q [a b])
             (zip+o a b [2 2])))
;=> 
([(0 0) (2 2)]
 [(1 0) (1 2)]
 [(2 0) (0 2)])

but the result should be:

([(0 0) (2 2)]
 [(1 0) (1 2)]
 [(2 0) (0 2)]
 [(0 1) (2 1)]
 [(0 2) (2 0)]
 [(1 1) (1 1)]
 [(1 2) (1 0)]
 [(2 1) (0 1)]
 [(2 2) (0 0)])


In the other way it seems to work:

(run* [q]
      (zip+o [1 1] [3 3] q))

;=> ((4 4))


Any idea?


Thanks 


-- 
You received this message because you are subscribed to the Google Groups 
"minikanren" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/minikanren.
For more options, visit https://groups.google.com/d/optout.

Reply via email to