Prolog newbie here who would like to know why these rules cannot stand on their own if I want to find out if something is the member of a list.
member(X, [X|_]).
member(X, [_|Y]) :- member(X,Y).
If I ask the following for the above rules:
member(will, [anna, eddie, pat, will, marjorie, donna]).
I get true, however if I remove:
member(X, [X|_]).
Just leaving the second rule, I get false. Why would this be if the second rule states that "X is a member of the list if X is a member of the tail of the list"
"will" is a member of the tail of this list.
And, why can
member(X, [X|_]).
stand alone and tell me when X is the head of the list (when the second rule cannot)?
Thank you.