PRODUCTS
Products Overview
Mathematica
Mathematica for Students
Mathematica Home Edition
Wolfram
CDF Player
(free download)
Computable Document Format (CDF)
web
Mathematica
grid
Mathematica
Wolfram
Workbench
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
Knowledge Base
Learning Center
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
DOCUMENTATION CENTER SEARCH
New to
Mathematica
?
Find your learning path
»
Mathematica
>
Core Language
>
List Manipulation
>
Applying Functions to Lists
>
MapIndexed
>
Mathematica
>
Data Manipulation
>
Handling Arrays of Data
>
Applying Functions to Lists
>
MapIndexed
>
Mathematica
>
Data Manipulation
>
Image Processing & Analysis
>
Basic Image Manipulation
>
Handling Arrays of Data
>
Applying Functions to Lists
>
MapIndexed
>
BUILT-IN MATHEMATICA SYMBOL
Applying Functions to Parts of Expressions
Tutorials »
|
MapAt
Map
SparseArray
See Also »
|
Applying Functions to Lists
Functional Programming
List Manipulation
Looping Constructs
More About »
MapIndexed
MapIndexed
applies
f
to the elements of
expr
, giving the part specification of each element as a second argument to
f
.
MapIndexed
applies
f
to all parts of
expr
on levels specified by
levelspec
.
MORE INFORMATION
MapIndexed
uses standard level specifications:
n
levels
through
n
Infinity
levels
through
Infinity
{
n
}
level
n
only
{
n
1
,
n
2
}
levels
through
The default value for
levelspec
in
MapIndexed
is
.
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
consists of numbers, symbols, and other objects that do not have subparts.
Level
corresponds to the whole expression.
With the option setting
Heads
->
True
,
MapIndexed
also applies to heads of expressions and their parts.
MapIndexed
traverses the parts of
expr
in a depth-first order, with leaves visited before roots.
»
MapIndexed
always effectively constructs a complete new expression and then evaluates it.
EXAMPLES
CLOSE ALL
Basic Examples
(3)
gives the indices of each part:
In[1]:=
Out[1]=
gives the indices of each part:
In[1]:=
Out[1]=
In[1]:=
Out[1]=
In[2]:=
Out[2]=
Scope
(6)
Map at level
(default):
Map down to level
:
Map at level
:
Map down to level
:
Map onto all elements of an expression:
Map only onto the "leaves" of the expression:
Negative levels:
Different heads at each level:
Map on levels
through
; the head has index
:
Generalizations & Extensions
(3)
MapIndexed
can be used on expressions with any head:
The function can be mapped onto the heads as well:
MapIndexed
works on sparse arrays:
Options
(2)
By default, the function is not mapped onto the heads:
Map onto the heads at all levels:
Applications
(5)
Label parts by position:
Use tooltips to show part numbers of subexpressions:
Convert a list to a polynomial:
Rotate lists based on position:
Obtain a list of all parts in an expression:
Properties & Relations
(2)
Leaves are visited before roots:
Using only the first argument is equivalent to using
Map
:
SEE ALSO
MapAt
Map
SparseArray
TUTORIALS
Applying Functions to Parts of Expressions
MORE ABOUT
Applying Functions to Lists
Functional Programming
List Manipulation
Looping Constructs
RELATED LINKS
NKS|Online
(
A New Kind of Science
)
New in 2