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
>
List Manipulation
>
Applying Functions to Lists
>
Map (/@)
>
Mathematica
>
Data Manipulation
>
Handling Arrays of Data
>
Applying Functions to Lists
>
Map (/@)
>
Mathematica
>
Data Manipulation
>
Image Processing & Analysis
>
Basic Image Manipulation
>
Handling Arrays of Data
>
Applying Functions to Lists
>
Map (/@)
>
BUILT-IN MATHEMATICA SYMBOL
Applying Functions to Parts of Expressions
Tutorials »
|
Apply
Scan
MapAll
MapAt
MapIndexed
MapThread
Level
Operate
Through
Thread
ParallelMap
ImageApply
See Also »
|
Applying Functions to Lists
Expressions
Functional Programming
Handling Arrays of Data
Image Processing & Analysis
Language Overview
List Manipulation
Looping Constructs
Parts of Expressions
Parts of Matrices
Mathematica Syntax
More About »
Map
Map
or
applies
f
to each element on the first level in
expr
.
Map
applies
f
to parts of
expr
specified by
levelspec
.
MORE INFORMATION
Map
uses standard level specifications:
n
levels 1 through
n
Infinity
levels 1 through
Infinity
{
n
}
level
n
only
{
n
1
,
n
2
}
levels
through
The default value for
levelspec
in
Map
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 -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
,
Map
includes heads of expressions and their parts.
Map
always effectively constructs a complete new expression and then evaluates it.
If
expr
is a
SparseArray
object,
Map
applies
f
to the values or subarrays that appear in
expr
.
EXAMPLES
CLOSE ALL
Basic Examples
(4)
Alternative input form:
Use explicit pure functions:
Map at top level:
Map at level 2:
Map at levels 1 and 2:
In[1]:=
Out[1]=
Alternative input form:
In[1]:=
Out[1]=
Use explicit pure functions:
In[1]:=
Out[1]=
In[2]:=
Out[2]=
Map at top level:
In[1]:=
Out[1]=
Map at level 2:
In[2]:=
Out[2]=
Map at levels 1 and 2:
In[3]:=
Out[3]=
Scope
(6)
Map at level 1 (default):
Map down to level 2:
Map at level 2:
Map on levels 0 through 2:
Map down to level 3:
Map on all levels, starting at level 1:
Map also at level 0:
Negative levels:
Positive and negative levels can be mixed:
Different heads at each level:
Include heads in the levels specified:
Generalizations & Extensions
(4)
Map
can be used on expressions with any head:
The function can be mapped onto the heads as well:
Functions with attribute
Listable
are mapped automatically:
Map
can be used on sparse arrays:
Options
(1)
By default, the function is not mapped onto the heads:
Applications
(3)
Reverse all sublists:
Add the same vector to every vector in a list:
Frame integers that are prime:
Properties & Relations
(5)
Leaves are visited before roots:
A function of several arguments can be mapped with
MapThread
:
MapIndexed
passes the index of an element to the mapped function:
MapAll
is equivalent to a specific level specification in
Map
:
Scan
does the same as
Map
, but without returning a result:
Possible Issues
(1)
Map
by default starts at level 1, so does not apply the function to the whole expression:
Neat Examples
(1)
Show nesting structure of an expression:
SEE ALSO
Apply
Scan
MapAll
MapAt
MapIndexed
MapThread
Level
Operate
Through
Thread
ParallelMap
ImageApply
TUTORIALS
Applying Functions to Parts of Expressions
MORE ABOUT
Applying Functions to Lists
Expressions
Functional Programming
Handling Arrays of Data
Image Processing & Analysis
Language Overview
List Manipulation
Looping Constructs
Parts of Expressions
Parts of Matrices
Mathematica
Syntax
RELATED LINKS
NKS|Online
(
A New Kind of Science
)
New in 1 | Last modified in 5