This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

MapAt

MapAt
applies f to the element at position n in expr. If n is negative, the position is counted from the end.
MapAt
applies f to the part of expr at position .
MapAt
applies f to parts of expr at several positions.
  • The list of positions used by MapAt is in the same form as is returned by the function Position. »
  • MapAt applies f repeatedly to a particular part if that part is mentioned more than once in the list of positions. »
Map onto the part at position :
Map onto multiple parts:
Map onto a more deeply nested part:
Map onto the part at position :
In[1]:=
Click for copyable input
Out[1]=
 
Map onto multiple parts:
In[1]:=
Click for copyable input
Out[1]=
 
Map onto a more deeply nested part:
In[1]:=
Click for copyable input
Out[1]=
A single element of the expression:
Negative numbers count from the end:
Map at a part at level 2:
Map at several elements:
Map at several nested parts:
MapAt can be used on expressions with any head:
The function can be mapped onto the heads as well:
Map can be used on sparse arrays:
Reset an element in a matrix:
Reverse the sign of an element in a matrix:
Enumerate cases with mapped onto successive elements:
Reverse the color of a cell at a random position at each step:
MapAt can use lists of parts returned by Position:
These are the subexpressions returned by Extract:
MapAt applies repeatedly if a part is mentioned repeatedly:
New in 1