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  (5)

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:

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:

Introduced in 1991
 (2.0)
 |
Updated in 2014
 (10.0)
2016
 (11.0)
2017
 (11.1)