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
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.