This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Tests  /
MemberQ

  • MemberQ[ list , form ] returns True if an element of list matches form, and False otherwise.
  • MemberQ[ list , form , levelspec ] tests all parts of list specified by levelspec.
  • form can be a pattern.
  • Example: MemberQ[ x^2, y^2 , x^_].
  • The first argument of MemberQ can have any head, not necessarily List.
  • See the Mathematica book: Section 1.8.5Section 2.3.5.
  • See also: FreeQ, Count, Cases, IntervalMemberQ.

    Further Examples

    The symbol a is clearly a member of the indicated list, but {a} is not.

    In[1]:=

    Out[1]=

    In[2]:=

    Out[2]=