Last active
August 22, 2017 15:49
-
-
Save infinite-Joy/1cc9cb8fe1e5e0be85b162d2c75686b1 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
/* | |
* This is a prolog code showing basic code patterns | |
* on how to write relationships between items and | |
* how to reason about them. | |
*/ | |
has(jack,apples). % jack has apples. | |
has(jack,plums). % jack has plums. | |
has(ann,plums). % ann has plums. | |
has(dan,money). % dan has money. | |
fruit(apples). % apple is fruit. | |
fruit(plums). % plums is fruit. | |
/* | |
* usage: swipl -q -f prolog_listing.pl -t fruit_listing | |
*/ | |
fruit_listing :- | |
listing(fruit), nl, halt. | |
/* | |
* usage: swipl -q -f prolog_listing.pl -t fruit_listing | |
*/ | |
main :- | |
has(X,apples), % who has apples | |
has(Y,money), % who has money | |
write(X), % write apple owner | |
put(10), % new line | |
write(Y), % write money owner | |
nl, halt. % new line and halt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment