(defne & rest)
Define a goal fn. Supports pattern matching. All patterns will be tried. See conde.
(defne match1 [x y]
([:foo :bar])
([:baz :qux]))
(run* [x y] (match1 x y)) ;; => ([:foo :bar] [:baz :qux])
(defne match2 [x y]
([[a b . tail] [b a . tail]]))
(run* [r] (match2 '(a b c d) r)) ;; => ((b a c d))
(defne match3 [x y]
([[a . _] [a . _]]))
(run* [r] (match3 [3 2 1] [3 4 5])) ;; => (_0)
;; adapted from:
;; http://stackoverflow.com/questions/11964055/constraining-two-vectors-to-be-in-the-same-domain-but-not-be-members-of-each-ot
(defne not-membero [x l]
([_ []])
([_ [?y . ?r]]
(!= x ?y)
(not-membero x ?r)))
(run* [q]
(not-membero q [:a :b :c])) ;; ((_0 :- (!= (_0 :a)) (!= (_0 :b)) (!= (_0 :c)))
(run* [q]
(membero q [1 2 3 4 5])
(not-membero q [2 4])) ;; (1 3 5)