[ library(lists) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]
Succeeds if Term is a member of the list List.
- Prolog term.
- List or a variable.
Unifies Term with the first matching element of the list List.
If List is not instantiated, memberchk/2 binds List to a new partial
list containing an element Term.
The definition of this Prolog library predicate is:
memberchk(X,[X|_]) :- !.
This predicate does not perform any type testing functions.
Modes and Determinism
- memberchk(+, +) is semidet
- memberchk(+, -) is det
Fails if Term is not a member of the list List.
memberchk(0,[1,B,2]). (gives B=0).
memberchk(1,[1,X]). (gives X=_g76).
member / 2