clojure - Understanding core.logic != -
i expect following expression return number of results, each of consists of 2 cons cells, 2 cons cells not equivalent. however, returns 0 results. why getting no results?
(run* [c1 c2] (fresh [lx ly x1 y1 x2 y2] (== lx [1 2]) (== ly [4 5]) (membero x1 lx) (membero x2 lx) (membero y1 ly) (membero y2 ly) (conso x1 y1 c1) (conso x2 y2 c2) (!= c1 c2)))
examples of expected results:
[(1 . 4) (2 . 5)]
[(1 . 4) (1 . 5)]
[(2 . 4) (2 . 5)]
i not expect return result [(1 . 4) (1 . 4)]
both spots in each cons equal.
if remove (!= c1 c2)
portion, 16 results, including both cons same.
i results expect if replace (!= c1 c2)
with:
(conde ((!= x1 x2)) ((!= y1 y2)))
which should same thing, explicitly checks 2 cells.
this not valid core.logic program. cannot use conso
tail not proper. minikanren in scheme let this, behavior undefined core.logic. i've amended docstring conso
reflect this. working program:
(run* [c1 c2] (fresh [lx ly x1 y1 x2 y2] (== lx [1 2]) (== ly [4 5]) (membero x1 lx) (membero x2 lx) (membero y1 ly) (membero y2 ly) (== [x1 y1] c1) (== [x2 y2] c2) (!= c1 c2)))
Comments
Post a Comment