Ancestors in Prolog

Asked

Viewed 61 times

1

Hello, I need to create a predicate that will return all the ancestors of a person. The point is that I can only pass one parameter to that function.

ancestor(Y, X) :- parent(Y, X).
ancestor(X) :- parent(Y, X), ancestor(Y, X).

Using two arguments in the second 'Ancestor' I can reach the expected result, however I need to pass only one argument as above.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.