Mathematica 9 is now available
 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]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.