In the previous section, it was pointed out that
If you have a ground term (or
one that is sufficiently instantiated) and you only want to know
whether it occurs in a list or not, you would like the membership test
to succeed only once.
memberchk/2 is a version of
member/2 that does this.
) can only be used to test whether a known
element occurs in a known list. It cannot be used to enumerate elements
of the list.
memberchk/2 commits to the first match and does not backtrack.
memberchk/2 in preference to
member/2, but only where its
restrictions are appropriate.