member/2
member(
?Element,
?List)
is true if Element occurs in the List. It may be used to test for an element or to enumerate all the elements by backtracking. Indeed, it may be used to generate the List!
In the context of this predicate, a term occurs in a list if it can be unified with an element of the list.
On backtracking, an attempt is made to unify Element with successive elements of List. If List is not a proper list, then on backtracking it is unified with lists of ever increasing length.
| ?- member(foo(X), [foo(1), bar(2), foo(3)]). X = 1 ? ; X = 3 ? ; no
ref-lte-acl,
library(lists)
.