10 Mar 2005
CS 3243 - FOL and Prolog
46
Function Membership Solution
lDefine two predicates:
l
lmember(X,[X|T]).
lmember(X,[Y|T]) :- member(X,T).
l
lA more elegant definition uses anonymous variables:
l
lmember(X,[X,_]).
lmember(X,[_|T]) :- member(X,T).
l
lAgain, the symbol _ indicates that the contents of that variable is unimportant.
l