0
% link(Origin,Destination,Speed,Length).
link(paris,milano,140,360).
link(paris,london,200,698).
link(berlin,atena,110,714).
link(atena,paris,90,370).
我需要讓我得到一個Path
從X市城市Y.幫助尋找路徑
route(Origin,Destination,TrainType,Path,Length,Duration).
我是新來的Prolog寫這條路線謂語,所以我寫了這樣的事情。我知道這是不正確的:
route(Origin,Destination,TrainType,Path,Legth,Duration) :-
link(Origin,City,Len),
City \= Origin,
NewLen is Length + Len,
route(City,Destination,TrainType,Path,NewLen,Duration).