【发布时间】:2018-12-23 07:59:55
【问题描述】:
我有一个序言程序来表示两个州之间的航班及其成本。
我的程序是这样的:
flight(newyork,washington,7). %its mean that there is a flight between both washington and newyork, newyork and washington with cost 7.
flight(lasvegas,losangeles,4).
flight(california,arizona,8).
route(A,B,C):-
flight(A,B,C);flight(B,A,C). %there is a route if there is a flight between A and B with cost C `OR` B and A with cost C.
现在,当我编写这样的查询时:
?-route(washington,newyork,7).
它给我true。这个查询对我很有用。
但是当我写这个查询时:
?-route(newyork,washington,7).
它首先给了我true 和false 之后。但我不想要这个。我只想要true,为什么它在true 之后给出false?为什么它给出两个输出?
【问题讨论】: