Map 
Details and Options
- Map uses standard level specifications:
-
n levels 1 through n Infinity levels 1 through Infinity {n} level n only {n1,n2} levels n1 through n2 - The default value for levelspec in Map is {1}.
- 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 an Association object, Map[f,expr] applies f to the values in the association. »
- If expr is a SparseArray object or structured array, Map[f,expr] applies f to the values or subarrays that appear in expr. »
- Map[f][expr] is equivalent to Map[f,expr].
- Parallelize[Map[f,expr]] or ParallelMap[f,expr] computes Map[f,expr] in parallel on all subkernels. »
Examples
open all close allBasic Examples (5)
Evaluate f on each element of a list:
Map[f, {a, b, c, d, e}]f /@ {a, b, c, d, e}(1 + g[#])& /@ {a, b, c, d, e}Function[x, x ^ 2] /@ {1, 2, 3, 4}Map[f, {{a, b}, {c, d, e}}]Map[f, {{a, b}, {c, d, e}}, {2}]Map[f, {{a, b}, {c, d, e}}, 2]Map[f][{a, b, c, d}]Map a function over values in Association:
Map[h, <|a -> b, c -> d|>]Scope (11)
Level Specifications (6)
Map[f, {{{{{a}}}}}]Map[f, {{{{{a}}}}}, 2]Map[f, {{{{{a}}}}}, {2}]Map[f, {{{{{a}}}}}, {0, 2}]Map[f, {{{{{a}}}}}, 3]Map on all levels, starting at level 1:
Map[f, {{{{{a}}}}}, Infinity]Map[f, {{{{{a}}}}}, {0, Infinity}]Map[f, {{{{{a}}}}}, -1]Map[f, {{{{{a}}}}}, -2]Map[f, {{{{{a}}}}}, -3]Positive and negative levels can be mixed:
Map[f, {{{{{a}}}}}, {2, -3}]Different heads at each level:
Map[f, h0[h1[h2[h3[h4[a]]]]], {2, -3}]Include heads in the levels specified:
Map[f, {{{{a}}}}, 2, Heads -> True]Types of Expressions (5)
Map can be used on expressions with any head:
Map[f, a + b + c + d]Map[f, x ^ 2 + y ^ 2, 2]Map can be used on sparse arrays:
SparseArray[{1 -> 1, 2 -> 2, 10 -> 10}]Map[f, %]Normal[%]Use Map with structured arrays, such as SymmetrizedArray:
SymmetrizedArray[{{1, 2} -> 1, {1, 3} -> 2, {2, 3} -> 3}, {3, 3}, Antisymmetric[All]]f /@ %Use Map to apply a function to the elements of a structured array of type QuantityArray:
QuantityArray[{{1, 2}, {3, 4}, {5, 6}}, "Meters"]Map[g, %, {2}]Map at the second level of a nested Association:
Map[h, <|a -> <|b -> c|>, d -> <|e -> f|>|>, {2}]Map at several levels in an Association:
Map[h, <|a -> <|b -> c|>, d -> {<|e -> f|>}|>, {1, 3}]Options (1)
Applications (4)
Reverse /@ {{a, b}, {c, d}, {e, f}}Add the same vector to every vector in a list:
Map[(# + {x, y})&, {{1, 1}, {2, 2}, {3, 3}, {4, 4}}]Frame integers that are prime:
If[PrimeQ[#], Framed[#], #]& /@ Range[20]Supply additional constant arguments by using a pure function:
Map[f[#, 3]&, {a, b, c}]Properties & Relations (9)
A function of several arguments can be mapped with MapThread:
MapThread[f, {{1, 2, 3}, {a, b, c}}]MapIndexed passes the index of an element to the mapped function:
MapIndexed[f, {a, b, c}]MapAll is equivalent to a specific level specification in Map:
Map[f, {{a, b}, {c}, {{d}}}, {0, ∞}]MapAll[f, {{a, b}, {c}, {{d}}}]Scan does the same as Map, but without returning a result:
Map[Print, {a, b}]Scan[Print, {a, b}]Functions with attribute Listable are mapped automatically:
Attributes[Sqrt]Sqrt[{1, 2, 3, 4}]Map[Sqrt, {1, 2, 3, 4}]ParallelMap computes Map in parallel:
ParallelMap[PrimeQ[2 ^ # - 1]&, Range[100, 110]]Map can be parallelized automatically, effectively using ParallelMap:
Parallelize[Map[PrimeQ[2 ^ # - 1]&, Range[100, 110]]]Map wraps an expression around parts of another expression:
Map[f, {x, y, z}]Comap wraps parts of an expression around another expression:
Comap[{f, g, h}, x]Map maps a function over the values in an association:
Map[f, <|a -> 1, b -> 2, c -> 3|>]KeyMap maps a function over the keys in an association:
KeyMap[f, <|a -> 1, b -> 2, c -> 3|>]KeyValueMap maps a function over the keys and values in an association (and returns a list):
KeyValueMap[f, <|a -> 1, b -> 2, c -> 3|>]AssociationMap maps a function over the rules in an association:
AssociationMap[Reverse, <|a -> 1, b -> 2, c -> 3|>]Map[f,assoc] is equivalent to AssociationThread[Keys[assoc]Map[f,Values[assoc]]]:
assoc = <|1 -> a, 2 -> b, 3 -> c|>;Map[f, assoc] === AssociationThread[Keys[assoc] -> Map[f, Values[assoc]]]Possible Issues (1)
Map by default starts at level 1, so does not apply the function to the whole expression:
Map[f, h1[h2[h3[x]]], -1]Map[f, h1[h2[h3[x]]], {0, -1}]See Also
Apply Scan MapAll MapAt MapIndexed MapApply MapThread SubsetMap AssociationMap KeyMap KeyValueMap ParallelMap Level Operate Comap Through Thread ImageApply
Function Repository: MapCases MapBatched JoinMap
Tech Notes
Related Guides
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2014 (10.0)
Text
Wolfram Research (1988), Map, Wolfram Language function, https://reference.wolfram.com/language/ref/Map.html (updated 2014).
CMS
Wolfram Language. 1988. "Map." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Map.html.
APA
Wolfram Language. (1988). Map. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Map.html
BibTeX
@misc{reference.wolfram_2026_map, author="Wolfram Research", title="{Map}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Map.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_map, organization={Wolfram Research}, title={Map}, year={2014}, url={https://reference.wolfram.com/language/ref/Map.html}, note=[Accessed: 13-June-2026]}