Created
January 3, 2012 22:57
-
-
Save frenchy64/1557417 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
;; As a goal | |
;; Non-relational | |
;; Accepts these patterns of arguments: | |
;; IOO | |
;; III | |
;; IOI | |
;; IIO | |
;; I=input (ground), O=output (not ground) | |
(defn items-colors-for-country [country item-name item-color] | |
(fresh [not-country] | |
(items item-name item-color) | |
(!= country not-country) | |
(conda | |
[(restricted-to country item-name) | |
(conda | |
[(not-allowed-in country item-name) | |
fail] | |
[succeed])] | |
[(restricted-to not-country item-name) | |
fail] | |
;; No entry in restricted-to for item-name | |
[(not-allowed-in country item-name) | |
fail] | |
[succeed]))) | |
(run* [q] | |
(fresh [country item-name item-color] | |
(== q [country item-name item-color]) | |
(conde | |
[(== 'US country)] | |
[(== 'UK country)] | |
[(== 'France country)] | |
[(== 'Australia country)]) | |
(items-colors-for-country country item-name item-color))) | |
;=> ([US Purse Blue] [UK Purse Blue] [US Banana Yellow] [US Car Red] [Australia Purse Blue] [Australia Banana Yellow] [France Banana Yellow]) | |
(run* [q] | |
(fresh [country item-name item-color] | |
(== q [country item-name item-color]) | |
(== item-color 'Blue) | |
(conde | |
[(== 'US country)] | |
[(== 'UK country)] | |
[(== 'France country)] | |
[(== 'Australia country)]) | |
(items-colors-for-country country item-name item-color))) | |
;=> ([US Purse Blue] [UK Purse Blue] [Australia Purse Blue]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment