Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Exercise 1
- loves(romeo, juliet).
- loves(juliet, romeo) :- loves(romeo, juliet).
- % Exercise 2
- male(albert).
- male(bob).
- male(bill).
- male(carl).
- male(charlie).
- male(dan).
- male(edward).
- female(alice).
- female(betsy).
- female(diana).
- % Exercise 3
- happy(albert).
- happy(alice).
- happy(bob).
- happy(bill).
- with_albert(alice).
- runs(albert) :- happy(albert).
- dances(alice) :- happy(alice), with_albert(alice).
- % Exercise 4
- does_alice_dance :- dances(alice), write('When Alice is happy and with Albert, she dances').
- % Exercise 5
- near_water(bob).
- swims(bob) :- happy(bob), near_water(bob).
- % Exercise 6
- parent(albert, bob).
- parent(albert, betsy).
- parent(albert, bill).
- parent(alice, bob).
- parent(alice, betsy).
- parent(alice, bill).
- parent(bob, carl).
- parent(bob, charlie).
- % Exercise 7
- get_grandchild :-
- parent(albert, X),
- parent(X, Y),
- write('Alberts grandchildren are: '),
- write(Y), nl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement