Testing if a value is in a list or a set: member contains

### 6.41.2 Testing if a value is in a list or a set: member contains

The member and contains commands determine whether or not an object is in a list; the difference between them is the order of the arguments (required for compatibility reasons).

- member takes two arguments:
  - c, a value.
  - L, a list or a set.
- member(c,L) returns 0 if c is not an element of L and otherwise returns n if c is in L and its first position has index n−1. 0 if c is not in L.

Examples.

- Input:
  member(2,[0,1,2,3,4,2])
  Output:

  3

- Input:
  member(2,%{0,1,2,3,4,2%})
  Output:

  3

- contains takes two arguments:
  - L, a list or a set.
  - c, a value.
- contains(L,c) returns 0 if c is not an element of L and otherwise returns n if c is in L and its first position has index n−1. 0 if c is not in L.

Examples.

- Input:
  contains([0,1,2,3,4,2],2)
  Output:

  3

- Input:
  contains(%{0,1,2,3,4,2%},2)
  Output:

  3