MapThread
Details
- MapThread works on Association objects.
- MapThread[f][expr] is equivalent to MapThread[f,expr].
- Parallelize[MapThread[f,{{a1,a2,…},{b1,b2,…},…}]] computes MapThread[f,{{a1,a2,…},{b1,b2,…},…}] in parallel on all subkernels. »
Examples
open all close allBasic Examples (4)
Apply f to corresponding pairs of elements:
MapThread[f, {{a, b, c}, {x, y, z}}]Apply f to elements of a matrix:
MapThread[f, {{{a, b}, {c, d}}, {{u, v}, {s, t}}}, 2]Apply f to corresponding values of associations:
MapThread[f, {<|a -> 1|>, <|a -> 2|>}]Use the operator form of MapThread:
MapThread[f][{{a, b, c, d}, {1, 2, 3, 4}}]Scope (2)
By default, MapThread threads over level 1 of the arguments:
MapThread[f, {{{a, b}, {c, d}}, {{u, v}, {w, x}}}]MapThread[f, {{{a, b}, {c, d}}, {{u, v}, {w, x}}}, 2]MapThread works with any number of expressions:
MapThread[f, {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}]Applications (3)
Set up an outer totalistic cellular automaton:
t = RandomInteger[1, 10]MapThread[f, {t, RotateLeft[t] + RotateRight[t]}]Divide eigenvectors by their corresponding eigenvalues:
Eigensystem[{{1, 3}, {2, 7}}]MapThread[#2 / #1&, %]//FullSimplifyApply the functions in a list to corresponding arguments:
MapThread[#1@#2&, {{f, g, h}, {x, y, z}}]Properties & Relations (6)
Add columns of elements in a matrix:
MapThread[Plus, {{a, b, c}, {u, v, w}, {x, y, z}}]Total[{{a, b, c}, {u, v, w}, {x, y, z}}]Get lists of elements in columns of a matrix:
MapThread[List, {{a, b, c}, {u, v, w}, {x, y, z}}]Transpose[{{a, b, c}, {u, v, w}, {x, y, z}}]MapThread works like Thread, but takes the function and arguments separately:
MapThread[f, {{a, b, c}, {x, y, z}}]Thread[f[{a, b, c}, {x, y, z}]]Thread evaluates the whole expression before threading:
Thread[D[{x, x y, x z}, {x, y, z}]]MapThread takes the function and its arguments separately:
MapThread[D, {{x, x y, x z}, {x, y, z}}]MapThread is a generalization of Map to functions of several variables:
Map[f, {a, b, c}]MapThread[f, {{a, b, c}}]MapThread[f, {{a, b, c}, {x, y, z}}]Compute MapThread in parallel:
Parallelize[MapThread[f, {{a, b, c}, {u, v, w}}]]Possible Issues (2)
All arguments must be lists of the same length:
MapThread[f, {{a, b, c}, t, {u, v, w}}]Thread repeats nonlist arguments as needed:
Thread[f[{a, b, c}, t, {u, v, w}]]MapThread combines associations in a list:
MapThread[f, {<|a -> 1|>, <|a -> 2|>}]Use Apply to combine values of an association:
Apply[f, <|a -> {1, 2}, b -> {3, 4}|>, {1}]See Also
Apply Map Thread Threaded Inner Transpose Comap Through
Function Repository: GeneralizedMapThread ArrayContractThread
Tech Notes
Related Guides
History
Introduced in 1991 (2.0) | Updated in 2014 (10.0) ▪ 2016 (11.0) ▪ 2017 (11.1)
Text
Wolfram Research (1991), MapThread, Wolfram Language function, https://reference.wolfram.com/language/ref/MapThread.html (updated 2017).
CMS
Wolfram Language. 1991. "MapThread." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/MapThread.html.
APA
Wolfram Language. (1991). MapThread. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MapThread.html
BibTeX
@misc{reference.wolfram_2026_mapthread, author="Wolfram Research", title="{MapThread}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/MapThread.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_mapthread, organization={Wolfram Research}, title={MapThread}, year={2017}, url={https://reference.wolfram.com/language/ref/MapThread.html}, note=[Accessed: 15-June-2026]}