PRODUCTS
Products Overview
Mathematica
Mathematica Student Edition
Mathematica Home Edition
Wolfram
CDF Player
(free download)
Computable Document Format (CDF)
web
Mathematica
grid
Mathematica
Wolfram
Workbench
Wolfram
SystemModeler
Wolfram
Finance Platform
Mathematica
Add-Ons
Wolfram|Alpha Products
SOLUTIONS
Solutions Overview
Engineering
Aerospace Engineering & Defense
Chemical Engineering
Control Systems
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
STEM Education Initiative
Higher Education
Community & Technical College Education
Primary & Secondary Education
Students
Technology
Computable Document Format (CDF)
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
Merchandise
SUPPORT
Support Overview
Mathematica
Documentation
Knowledge Base
Learning Center
Technical Services
Community & Forums
Training
Does My Site Have a License?
Wolfram User Portal
COMPANY
About Wolfram Research
News
Events
Wolfram Blog
Partnerships
Employment Opportunities
History of
Mathematica
Stephen Wolfram's Home Page
Contact Us
OUR SITES
All Sites
Wolfram|Alpha
Demonstrations Project
MathWorld
Integrator
Wolfram Functions Site
Mathematica Journal
Wolfram Media
Wolfram
Tones
Wolfram Science
Stephen Wolfram
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE
DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.
DOCUMENTATION CENTER SEARCH
New to
Mathematica
?
Find your learning path
»
Mathematica
>
Core Language
>
Rules & Patterns
>
Pattern Matching Functions
>
Position
>
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
gives a list of the positions at which objects matching
pattern
appear in
expr
.
Position
finds only objects that appear on levels specified by
levelspec
.
Position
gives the positions of the first
n
objects found.
MORE INFORMATION
Position
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
through
n
Infinity
levels
through
Infinity
{
n
}
level
n
only
{
n
1
,
n
2
}
levels
through
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
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
occurs:
Find all positions at which
to any power appears:
Find only those down to level 2:
Find the positions at which
occurs:
In[1]:=
Out[1]=
In[2]:=
Out[2]=
Find all positions at which
to any power appears:
In[1]:=
Out[1]=
Find only those down to level 2:
In[2]:=
Out[2]=
Scope
(2)
Find the positions of the first 2
's that appear on level 1:
Depth-first traversal gives longer lists of indices first:
Generalizations & Extensions
(1)
Position
works with any head, not just
List
:
Options
(1)
Properties & Relations
(1)
Use
Extract
to extract parts based on results from
Position
:
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
NKS|Online
(
A New Kind of Science
)
New in 1