Okay, my last prolog question. It's the common geneaology problem.
I am suppose to take a list of facts and have a function called descendant that will return a list that has all the descendants. For example:
Given the rules:
parent('Bob', 'Tim').
parent('Joe', 'Bob').
The function call:
descendant('Joe', X).
should return:
X = ['Bob', 'Tim'].
I can get it to return the immediate descendant of 'Joe' but not the full line. Here's what I have.
% Recursive case
descendant(X,DList) :- parent(X,A), NewDList = [A|DList],
descendant(A, NewDList).
% Base case, I have a feeling this is wrong.
descendant(_,[]).
This code only seems to return true or false, or just an empty [].
I could use some help on what I might need to look at. Thanks.