is true when Element does not occur in the List. For
to instantiate Element in any way would be meaningless, as there are
infinitely many terms that do not occur in any given list.
nonmember/2 should only be used when List
and Element are sufficiently instantiated that you can tell whether
Element occurs in List or not without instantiating any variables.
If this requirement is not met, the answers generated may not be exactly
what you would expect from the logic.
For example, some valid uses of
| ?- nonmember(a, [x,y,z]). yes | ?- nonmember(x, [x,y,z]). no
In the following examples,
nonmember/2 is invalidly used with
insufficiently instantiated arguments. In these cases it simply fails.
| ?- nonmember(X, [x,y,z]). no | ?- nonmember(x, [X]). no | ?- nonmember(x, X). no
nonmember/2 to check whether a known element occurs in a known
list, in preference to
\+ member/2 or