PRODUCTS
Mathematica
Mathematica Home Edition
Mathematica for Students
Mathematica for the Classroom
grid
Mathematica
Wolfram Lightweight Grid Manager
web
Mathematica
Mathematica Player
(free download)
Mathematica Player Pro
Wolfram
Workbench
Mathematica
Applications
SOLUTIONS
Engineering
Aerospace Engineering & Defense
Chemical Engineering
Electrical Engineering
Image Processing
Industrial Engineering
Materials Science
Mechanical Engineering
Operations Research
Optics
Petroleum Engineering
Biotechnology & Medicine
Bioinformatics
Medical Imaging
Finance, Statistics, & Business Analysis
Actuarial Sciences
Data Analysis & Mining
Econometrics
Economics
Financial Engineering & Mathematics
Financial Risk Management
Statistics
Software Engineering & Content Delivery
Authoring & Publishing
Interface Development
Software Engineering
Web Development
Science
Astronomy
Biological Sciences
Chemistry
Environmental Sciences
Geosciences
Social & Behavioral Sciences
Design, Arts, & Entertainment
Game Design, Special Effects, & Generative Art
Education
Higher Education
Precollege Education
Students
Technology
Interactive Deployment
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
PURCHASE
Online Store
Other Ways to Buy
Volume & Site Licensing
Contact Sales
Software
Service
Upgrades
Training
Books
FOR USERS
All User Resources
Product Registration
Technical Support
Customer Service
Developer Support
Does My Site Have a License?
Free Seminars
Learning Center
Training
Custom Group Seminars
Documentation & Examples
Tutorial Screencasts
Video Gallery
Demonstrations Project
Education Portal
Student Resources
COMPANY
About Wolfram Research
News & Events
Wolfram Blog
Employment Opportunities
History of
Mathematica
Stephen Wolfram's Home Page
Contact Us
OUR SITES
Wolfram|Alpha
Demonstrations Project
Wolfram Blog
MathWorld
Integrator
Wolfram Functions Site
Mathematica Journal
Wolfram Library Archive
Wolfram
Tones
Wolfram Science
Stephen Wolfram
DOCUMENTATION CENTER SEARCH
Mathematica
>
Core Language
>
Rules & Patterns
>
Pattern Matching Functions
>
Built-in
Mathematica
Symbol
Testing and Searching List Elements
Levels in Expressions
Applying Functions to Parts of Expressions
Finding Expressions That Match a Pattern
Tutorials »
|
Cases
Count
StringPosition
LengthWhile
Ordering
SparseArray
ReplaceList
Insert
Delete
ArrayRules
Extract
See Also »
|
Discrete & Integer Data
Elements of Lists
Expressions
Handling Arrays of Data
Language Overview
List Manipulation
Parts of Expressions
Parts of Matrices
Pattern Matching Functions
Rules & Patterns
More About »
Position
Position
[
expr
,
pattern
]
gives a list of the positions at which objects matching
pattern
appear in
expr
.
Position
[
expr
,
pattern
,
levelspec
]
finds only objects that appear on levels specified by
levelspec
.
Position
[
expr
,
pattern
,
levelspec
,
n
]
gives the positions of the first
n
objects found.
MORE INFORMATION
Position
[
expr
,
pattern
]
tests all the subparts of
expr
in turn to try and find ones that match
pattern
.
Position
returns a list of positions in a form suitable for use in
Extract
,
ReplacePart
and
MapAt
. The form is different from the one used in
Part
.
The default level specification for
Position
is
{0,
Infinity
}
, with
Heads
->
True
.
A part specification
{}
returned by
Position
represents the whole of
expr
.
Position
[
list
,
pattern
, {1},
Heads
->
False
]
finds positions only of objects that appear as complete elements of
list
.
Position
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
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
0
corresponds to the whole expression.
With the default option setting
Heads
->
True
,
Position
includes heads of expressions, and their parts.
Position
traverses expressions in depth-first order, yielding lists of indices in lexicographic order.
EXAMPLES
CLOSE ALL
Basic Examples
(2)
Find the positions at which
b
occurs:
In[1]:=
Out[1]=
In[2]:=
Out[2]=
Find all positions at which
x
to any power appears:
In[1]:=
Out[1]=
Find only those down to level 2:
In[2]:=
Out[2]=
Scope
(2)
Generalizations & Extensions
(1)
Options
(1)
Properties & Relations
(1)
Possible Issues
(1)
SEE ALSO
Cases
Count
StringPosition
LengthWhile
Ordering
SparseArray
ReplaceList
Insert
Delete
ArrayRules
Extract
TUTORIALS
Testing and Searching List Elements
Levels in Expressions
Applying Functions to Parts of Expressions
Finding Expressions That Match a Pattern
MORE ABOUT
Discrete & Integer Data
Elements of Lists
Expressions
Handling Arrays of Data
Language Overview
List Manipulation
Parts of Expressions
Parts of Matrices
Pattern Matching Functions
Rules & Patterns
RELATED LINKS
Demonstrations with Position
(
Wolfram Demonstrations Project
)
NKS|Online
(
A New Kind of Science
)
New in 1