MapThread

MapThread[f,{{a1,a2,},{b1,b2,},}]

gives {f[a1,b1,],f[a2,b2,],}.

MapThread[f,{expr1,expr2,},n]

applies f to the parts of the expri at level n.

MapThread[f]

represents an operator form of MapThread that can be applied to an expression.

Details

Examples

open allclose all

Basic Examples  (4)

Apply f to corresponding pairs of elements:

Apply f to elements of a matrix:

Apply f to corresponding values of associations:

Use the operator form of MapThread:

Scope  (2)

By default, MapThread threads over level 1 of the arguments:

Thread over level 2:

MapThread works with any number of expressions:

Applications  (3)

Set up an outer totalistic cellular automaton:

Divide eigenvectors by their corresponding eigenvalues:

Apply the functions in a list to corresponding arguments:

Properties & Relations  (6)

Add columns of elements in a matrix:

Get lists of elements in columns of a matrix:

MapThread works like Thread, but takes the function and arguments separately:

Thread evaluates the whole expression before threading:

MapThread takes the function and its arguments separately:

MapThread is a generalization of Map to functions of several variables:

Compute MapThread in parallel:

Possible Issues  (2)

All arguments must be lists of the same length:

Thread repeats nonlist arguments as needed:

MapThread combines associations in a list:

Use Apply to combine values of an association:

Wolfram Research (1991), MapThread, Wolfram Language function, https://reference.wolfram.com/language/ref/MapThread.html (updated 2017).

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_2023_mapthread, author="Wolfram Research", title="{MapThread}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/MapThread.html}", note=[Accessed: 18-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_mapthread, organization={Wolfram Research}, title={MapThread}, year={2017}, url={https://reference.wolfram.com/language/ref/MapThread.html}, note=[Accessed: 18-March-2024 ]}