Search for all pages containing MapAt
MapAt
✖
MapAt
applies f to the element at position n in expr. If n is negative, the position is counted from the end.
Details
- MapAt[f,expr,{i,j,…}] or MapAt[f,expr,{{i,j,…}}] applies f to the part expr[[i,j,…]].
- MapAt[f,expr,{{i1,j1,…},{i2,j2,…},…}] applies f to parts expr[[i1,j1,…]], expr[[i2,j2,…]], …. »
- The list of positions used by MapAt is in the same form as is returned by the function Position. »
- MapAt works on Association objects, using the same specification for keys as in Part.
- MapAt applies f repeatedly to a particular part if that part is mentioned more than once in the list of positions. »
- MapAt[f,pos][expr] is equivalent to MapAt[f,expr,pos].
Examples
open allclose allBasic Examples (8)Summary of the most common use cases
Map f onto the part at position 2:
https://wolfram.com/xid/0j4y4h7s-kqn
https://wolfram.com/xid/0j4y4h7s-hfz
Map f onto a more deeply nested part:
https://wolfram.com/xid/0j4y4h7s-qvf
Map f onto the second element of all top-level parts (the "second column"):
https://wolfram.com/xid/0j4y4h7s-td5sej
https://wolfram.com/xid/0j4y4h7s-bocy24
Use Key to specify position:
https://wolfram.com/xid/0j4y4h7s-gu7xmg
For string keys, Key is not needed:
https://wolfram.com/xid/0j4y4h7s-9hcemd
Use negative position in an association:
https://wolfram.com/xid/0j4y4h7s-bhx0la
Use the operator form of MapAt:
https://wolfram.com/xid/0j4y4h7s-l8wsya
Scope (9)Survey of the scope of standard use cases
Part Specifications (9)
A single element of the expression:
https://wolfram.com/xid/0j4y4h7s-dbq1qd
Negative numbers count from the end:
https://wolfram.com/xid/0j4y4h7s-15rk63
https://wolfram.com/xid/0j4y4h7s-ouhobd
https://wolfram.com/xid/0j4y4h7s-g0d4c0
https://wolfram.com/xid/0j4y4h7s-iww2j9
Map using Span syntax:
https://wolfram.com/xid/0j4y4h7s-vfvmq
Map f at a more deeply nested part:
https://wolfram.com/xid/0j4y4h7s-3ke4b
https://wolfram.com/xid/0j4y4h7s-fz3uj
https://wolfram.com/xid/0j4y4h7s-jhzbxv
Generalizations & Extensions (4)Generalized and extended use cases
MapAt can be used on expressions with any head:
https://wolfram.com/xid/0j4y4h7s-r7z
https://wolfram.com/xid/0j4y4h7s-v3o
Key and integer part specifications in associations are different:
https://wolfram.com/xid/0j4y4h7s-fn6qcg
The function can be mapped onto the heads as well:
https://wolfram.com/xid/0j4y4h7s-j2f
Map can be used on sparse arrays:
https://wolfram.com/xid/0j4y4h7s-3at6ak
https://wolfram.com/xid/0j4y4h7s-4cvtqo
Applications (4)Sample problems that can be solved with this function
https://wolfram.com/xid/0j4y4h7s-j9a
Reverse the sign of an element in a matrix:
https://wolfram.com/xid/0j4y4h7s-vu5
Enumerate cases with f mapped onto successive elements:
https://wolfram.com/xid/0j4y4h7s-l48
Reverse the color of a cell at a random position at each step:
https://wolfram.com/xid/0j4y4h7s-kvg
Properties & Relations (2)Properties of the function, and connections to other functions
MapAt can use lists of parts returned by Position:
https://wolfram.com/xid/0j4y4h7s-ite
https://wolfram.com/xid/0j4y4h7s-ybx
https://wolfram.com/xid/0j4y4h7s-kva
These are the subexpressions returned by Extract:
https://wolfram.com/xid/0j4y4h7s-qdw84h
MapAt applies f repeatedly if a part is mentioned repeatedly:
https://wolfram.com/xid/0j4y4h7s-krg
Possible Issues (1)Common pitfalls and unexpected behavior
Wolfram Research (1988), MapAt, Wolfram Language function, https://reference.wolfram.com/language/ref/MapAt.html (updated 2014).
Text
Wolfram Research (1988), MapAt, Wolfram Language function, https://reference.wolfram.com/language/ref/MapAt.html (updated 2014).
Wolfram Research (1988), MapAt, Wolfram Language function, https://reference.wolfram.com/language/ref/MapAt.html (updated 2014).
CMS
Wolfram Language. 1988. "MapAt." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/MapAt.html.
Wolfram Language. 1988. "MapAt." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/MapAt.html.
APA
Wolfram Language. (1988). MapAt. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MapAt.html
Wolfram Language. (1988). MapAt. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MapAt.html
BibTeX
@misc{reference.wolfram_2024_mapat, author="Wolfram Research", title="{MapAt}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/MapAt.html}", note=[Accessed: 22-December-2024
]}
BibLaTeX
@online{reference.wolfram_2024_mapat, organization={Wolfram Research}, title={MapAt}, year={2014}, url={https://reference.wolfram.com/language/ref/MapAt.html}, note=[Accessed: 22-December-2024
]}