Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* 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 -t fruit_listing
fruit_listing :-
listing(fruit), nl, halt.
* usage: swipl -q -f -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