[英]How to correct predicate on Prolog?
I have the following prolog code: 我有以下序言代码:
predicates
like(string)
clauses
like(apple).
like(girl).
q :- like(A),write(A).
goal q.
How to get two solutions? 如何获得两个解决方案?
using findall predicate http://cs.union.edu/~striegnk/learn-prolog-now/html/node96.html 使用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).
or using fail 或使用失败
domains
Z = symbol*
predicates
like(symbol)
clauses
like(apple).
like(girl).
goal like(X),write(X),nl,fail.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.