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|_]) :- !. memberchk(X,[_|T]):- memberchk(X,T).This predicate does not perform any type testing functions.
Success: memberchk(0,[1,B,2]). (gives B=0). memberchk(1,[1,X]). (gives X=_g76). memberchk(1,X), memberchk(2,X). (gives X=[1,2|_g98]). Fail: memberchk(0,[1,2,3,4]).