This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / question on PROLOG programming?neighbor(city1, city2).
neighbor(city2, city3).
neighbor(city3, city4).
neighbor(city4, city5).
to find two neighbors:
neighbors(C1, C2) :- neighbor(C1, C2).
neighbors(C1, C2) :- neighbor(C2, C1).
now what about find out all cities nearby from east to west, ex.
find_nearby_city(city3, X) :- ?????
the output should be:
X = city4; city2; city5; city1; no.
any help apreciated!
-redspider(红蜘蛛);
2007-10-16
{403}
(#3996407@0)
-
已经忘了prolog了。印象中比其它语言简单多了,用递归的方式描述问题和初始情况就完了。现在不记得了。等别人来回答或者你自己看看书吧。
-wangqingshui(忘情水);
2007-10-20
(#4004382@0)