PRODUCTS
PURCHASE
FOR USERS
COMPANY
OUR SITES
DOCUMENTATION CENTER SEARCH
Mathematica
>
Pattern Matching Functions
>
Built-in
Mathematica
Symbol
Testing and Searching List Elements
Putting Constraints on Patterns
Tutorials »
|
FreeQ
Element
Count
Cases
IntervalMemberQ
See Also »
|
Elements of Lists
Expressions
Language Overview
List Manipulation
Pattern Matching Functions
Rules & Patterns
Testing Expressions
More About »
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
.
MORE INFORMATION
form
can be a pattern.
The first argument of
MemberQ
can have any head, not necessarily
List
.
MemberQ
[
list
,
form
]
immediately tests whether any expression in
list
matches
form
;
Element
[
x
,
dom
]
asserts that
x
is an element of the symbolic domain
dom
.
MemberQ
uses standard level specifications:
n
levels
1
through
n
Infinity
levels
1
through
Infinity
{
n
}
level
n
only
{
n
1
,
n
2
}
levels
n
1
through
n
2
The default value for
levelspec
in
MemberQ
is
{1}
.
A positive level
n
consists of all parts of
expr
specified by
n
indices.
A negative level
-
n
consists of all parts of
expr
with depth
n
.
Level
-1
consists of numbers, symbols and other objects that do not have subparts.
Level
0
corresponds to the whole expression.
With the option setting
Heads
->
True
,
MemberQ
looks at heads of expressions, and their parts.
EXAMPLES
CLOSE ALL
Basic Examples
(1)
Test whether
2
is a member of a list:
In[1]:=
Out[1]=
Scope
(2)
Applications
(1)
Possible Issues
(3)
SEE ALSO
FreeQ
Element
Count
Cases
IntervalMemberQ
TUTORIALS
Testing and Searching List Elements
Putting Constraints on Patterns
MORE ABOUT
Elements of Lists
Expressions
Language Overview
List Manipulation
Pattern Matching Functions
Rules & Patterns
Testing Expressions
RELATED LINKS
NKS|Online
(
A New Kind of Science
)
New in 1
© 2008 Wolfram Research, Inc.