fd/distinct在元素位于有限域而不是 的情况下使用有什么好处distincto?
以下全部返回([0 1] [1 0])。
;;; With distincto
(run* [q]
(fresh [x y]
(fd/in x y (fd/interval 1))
(distincto [x y])
(== q [x y])))
;;; With fd/distinct
(run* [q]
(fresh [x y]
(fd/in x y (fd/interval 1))
(fd/distinct [x y])
(== q [x y])))
;;; Without fd at all.
(let [interval [0 1]]
(run* [q]
(fresh [x y]
(membero x interval)
(membero y interval)
(distincto [x y])
(== q [x y]))))
值得注意的是,虽然看起来你可以distincto在任何你可以使用的地方使用(但不是相反),但对于和fd/distinct却不能这样说。memberofd/in