Hello everyone!
I'm struggling with this simple relation, the results are incomplete, and I
don't understand why.
I'm beginning with core.logic I don't know if it is a bug or my bad
understanding of it.
(require '[clojure.core.logic :as l])
(require '[clojure.core.logic.fd :as fd])
(defn zip+o [x y z]
(l/conde
[(l/== () x) (l/== () y) (l/== () z)]
[(l/fresh [fx rx fy ry fz rz]
(l/conso fx rx x)
(l/conso fy ry y)
(l/conso fz rz z)
(fd/in fx fy fz (fd/interval 10))
(fd/+ fx fy fz)
(zip+o rx ry rz))]))
; the same with defne macro
(comment
(l/defne zip+o [x y z]
([() () ()])
([[fx . rx]
[fy . ry]
[fz . rz]]
(fd/in fx fy fz (fd/interval 10))
(fd/+ fx fy fz)
(zip+o rx ry rz))))
(def expected-solutions
#{{:x [0 0] :y [1 1]}
{:x [0 1] :y [1 0]}
{:x [1 1] :y [0 0]}
{:x [1 0] :y [0 1]}})
(l/run* [q]
(l/fresh [x y]
(l/== q {:x x :y y})
(zip+o x y [1 1])))
;=> ({:x (1 0), :y (0 1)}
; {:x (0 0), :y (1 1)})
--
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.