I have following clauses:
num_parent(adam, X) :- !, X = 0.
num_parent(eve, X) :- !, X = 0.
num_parent(X, 2).
When I typed the query:
num_parent(eve,X).
It only returns:
X = 0.
which is what I want.
But when I typed this query:
num_parent(X,0).
it only returns:
X = adam.
So how can I modify the clauses to make it return:
X = adam;
X = eve.
Thanks
First, try to formulate what you want in plain English. You probably want to say:
What about Lilith? Never mind, let's stick to your reading.
As you can see, it is a bit cumbersome to define this: You have to mention each exceptional person twice. Easy to make an error.
With
if_/3available inlibrary(reif)for SICStus and SWI you can write more succinctly:And now some uses: