Created
March 24, 2012 16:26
-
-
Save reiddraper/2184849 to your computer and use it in GitHub Desktop.
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 characters
| (use 'clojure.core.logic) | |
| (defne all-in [x mems] | |
| ([[?a . ?b] mems] | |
| (membero ?a mems) | |
| (all-in ?b mems)) | |
| ([() _])) | |
| (defrel cocktail n) | |
| (fact cocktail :martini) | |
| (fact cocktail :martinez) | |
| (fact cocktail :manhattan) | |
| (fact cocktail :ginmule) | |
| (defrel ingredient i) | |
| (fact ingredient :a) | |
| (fact ingredient :b) | |
| (fact ingredient :c) | |
| (fact ingredient :d) | |
| (defrel ingredients n i) | |
| (fact ingredients :martini [:a :b]) | |
| (fact ingredients :martinez [:a :b :c]) | |
| (fact ingredients :manhattan [:b :d]) | |
| (fact ingredients :ginmule [:c :b]) | |
| (run* [q] | |
| (fresh [a b c x y z r s t] | |
| (!= a b) | |
| (!= b c) | |
| (!= a c) | |
| (!= x y) | |
| (!= y z) | |
| (!= x z) | |
| (cocktail a) | |
| (cocktail b) | |
| (cocktail c) | |
| (ingredients a r) | |
| (ingredients b s) | |
| (ingredients c t) | |
| (all-in r [x y z]) | |
| (all-in s [x y z]) | |
| (all-in t [x y z]) | |
| (ingredient x) | |
| (ingredient y) | |
| (ingredient z) | |
| (== q [a b c]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment