我有以下prolog代码:
predicates
like(string)
clauses
like(apple).
like(girl).
q :- like(A),write(A).
goal q.
如何获得两种解决方案?
使用 findall 谓词http://cs.union.edu/~striegnk/learn-prolog-now/html/node96.html
domains
Z = symbol*
predicates
like(symbol)
q(symbol)
clauses
like(apple).
like(girl).
q(A) :- like(A).
goal findall(X,q(X),Z),write(Z).
或使用失败
domains
Z = symbol*
predicates
like(symbol)
clauses
like(apple).
like(girl).
goal like(X),write(X),nl,fail.