我正在尝试实现membero
in的反面clojure.core.logic
,但它返回两个值而不是一个。否则,它可以正常工作(当值在列表中时不返回任何内容,当不在列表中时返回)。
(defne nonmembero
"A relation where l is a collection, such that l does not contain x"
[x l]
([_ ()])
([_ [head]]
(!= x head))
([_ [head . tail]]
(!= x head)
(nonmembero x tail)))
示例运行:
user> (run* [x] (nonmembero 1 [2 3 4 5]))
(_0 _0)
user> (run* [x] (nonmembero 1 [2 3 1 4 5]))
()