Given facts such as:
- Jake is smarter than Nik
- Nik is smarter than Wes
- Wes is smarter than Dik
Write a recursive program that will determine that Jake's is smarter than Dik's.
The solution that I have is:
smarter(jake, nik).
smarter(nik, wes).
smarter(wes, dik).
smarter(X, Y) :-
smarter(X, Z),
smarter(Z, Y).
The output:
?- smarter(jake, dik).
True
but when I swap it:
?- smarter(dik, jake)
The output will show "ERROR: Out of local stack" I need the output to show "False". How do I fix it?
Thanks