Created
December 19, 2012 04:00
Revisions
-
gfredericks created this gist
Dec 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ (defn condr* [& goals] (if (= 1 (count goals)) (first goals) (let [goals (shuffle goals)] (conde [(first goals)] [(apply condr* (rest goals))])))) (defmacro condr "Same as conde but clauses are scrambled on each call." [& clauses] `(condr* ~@(for [clause clauses] (cons `all clause)))) ;; example usage (defn listso [x] (condr [(membero x [:a :b :c])] [(== [] x)] [(fresh [a b] (listso a) (listso b) (== [a b] x))]))