1
votes

I am learning Prolog. I wrote some simple facts. But it seems that Prolog is not giving me right answers. Please help me understand what I am doing wrong here.

facts - weather.pl

weather(pheonix,summer,hot).   
weather(pheonix,winter,warm).  
weather(la,summer,warm).

When I run this in swi-prolog as follows

?- weather(City,_,warm).
City = pheonix .

Result is only shown as pheonix. But la is also warm. Why is it not given as an answer?

2

2 Answers

2
votes

You need to look at the answer very, very closely:

City = pheonix .
              ^ SPACE!

There is a space between the answer substitution and the dot. This little hint tells us: You have stopped asking for further answers. Try the query again and this time type SPACE or ; but do not type RETURN, for it will again stop the answers.

1
votes

Typically, after first answer is written, you can type some key, usually ";", to backtrack and receive another answer.