使用Prolog进行逻辑编程:
考虑该计划:
f(X) :- !, X = a.
f(X) :- !, X = b.
f(X) :- X = c.
P分别为查询f(a),f(b)和f(c)返回什么?
考虑该计划:
f(X) :- X = a, !.
f(X) :- X= b, !.
f(X) :- X = c.
P分别为查询f(a),f(b)和f(c)返回什么?
答案 0 :(得分:0)
P分别为查询f(a),f(b)和f(c)返回什么?
f(X) :- !, X = a. f(X) :- !, X = b. f(X) :- X = c.
?- f(a).
true.
?- f(b).
false.
?- f(c).
false.
f(X) :- X = a, !. f(X) :- X = b, !. f(X) :- X = c.
?- f(a).
true.
?- f(b).
true.
?- f(c).
true.