5
を使用する利点は、要素がdistincto
の代わりに有限のドメインにある場合はどうなりますか?core.logicのdistincto対fd/distinct
以下はすべて返品([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]))))
、あなたが同じmembero
とfd/in
のために言うことができない、あなたはfd/distinct
(ただし、他の方法で回避)を使用することができます任意の場所でdistincto
を使用することが表示されますが。