I recently started learning
Prolog and have come across an issue.
The following has been loaded into
likes(john, apple). likes(john, pear). likes(john, grapes). likes(bill, mango). likes(bill, apple).
I am writing a predicate
all_like(What, List) that should return
True if all the people in
List like the fruit in
true ; false.
I have the following code:
all_like(What,List) :- check_list(What,List). check_list(What,) :- write('true'). check_list(What, [X|Rest]) :- likes(X,What), check_list(What,Rest). check_list(What, [X|Rest]) :- \+ likes(X,What), write('false').
My results are:
true true .
false true .
Would anyone know why I'm getting these results?
What is the significance of the second boolean value being outputted?
Finally, is the
. appearing after a space of significance?
Thank you for your help.