Elementwise[f][{x1,…,xn},{y1,…,yn}]
gives {f[x1,y1],…,f[xn,yn]}.
Elementwise[f][arg1,…]
threads over any lists in arg1,….
Elementwise
Elementwise[f][{x1,…,xn},{y1,…,yn}]
gives {f[x1,y1],…,f[xn,yn]}.
Elementwise[f][arg1,…]
threads over any lists in arg1,….
Details
- Elementwise is typically used to make non-listable functions behave as if they were listable.
Examples
open all close allBasic Examples (4)
Replace negative numbers with 0:
Elementwise[Max][{1, -1, 3, -4, 5}, 0]Find which elements of a list are less than one:
Elementwise[Less][{1, 0, 2, -1}, 1]Elementwise[LessThan[1]][{1, 0, 2, -1}]Choose matrix elements that have the largest square:
Elementwise[If[#1^2 >= #2^2, #1, #2]&][(| | | |
| -- | -- | -- |
| -9 | -5 | -7 |
| -2 | -4 | 1 |
| -3 | -8 | -4 |), (| | | |
| -- | -- | -- |
| -1 | 2 | -5 |
| 5 | -2 | -3 |
| 4 | 6 | 3 |)]Add angle brackets to each of a list of strings:
Elementwise[StringJoin]["<", RandomWord[5], ">"]Scope (5)
Greater does not thread over lists by default:
Greater[{1, -1, 3, -4, 5}, 0]Use Elementwise[Greater] instead to make it behave as a listable function:
Elementwise[Greater][{1, -1, 3, -4, 5}, 0]Min returns the minimum value in its arguments:
Min[2, {-4, 2}, {{8, 5}, {-1, 6}}]Use Elementwise[Min] to thread its arguments to the deepest possible level:
Elementwise[Min][2, {-4, 1}, {{8, 5}, {0, 6}}]Effectively this is the threading operation performed:
Block[{min},
SetAttributes[min, Listable];
min[2, {-4, 1}, {{8, 5}, {0, 6}}]
]Take a TabularColumn object of dates:
TabularColumn[RandomDate[10 ^ 5]]Extract efficiently respective columns for their months and days:
RepeatedTiming[mds = Elementwise[DateValue[#, {"Month", "Day"}]&][%]]Construct a Tabular object with those two columns:
ToTabular[{"month" -> mds[[All, 1]], "day" -> mds[[All, 2]]}, "Columns"]Take a Tabular object with two columns of triples:
tab = Tabular[{{{1, 2, 3}, 2}, {{2, -1, 4}, 1}}, {"vector", "scalar"}]TransformColumns[tab, "comp" -> Function[Elementwise[Greater][#vector, #scalar]]]Elementwise works with Threaded:
Elementwise[f][{{1, 2, 3}, {4, 5, 6}}, {a, b}]Elementwise[f][{{1, 2, 3}, {4, 5, 6}}, Threaded[{α, β, γ}]]Applications (2)
Get full names by combining first and last names:
firstNames = TabularColumn[{"Pierce", "Sean", "Daniel", "Timothy", "George", "Roger", "David"}];
lastNames = TabularColumn[{"Brosnan", "Connery", "Craig", "Dalton", "Lazenby", "Moore", "Niven"}];Elementwise[StringJoin][firstNames, " ", lastNames]Normal[%]Find how many notable books written by Ernest Hemingway were first published before his death:
dates = EntityValue[Entity["Person", "ErnestHemingway::8gktg"][EntityProperty["Person", "NotableBooks"]], EntityProperty["Book", "FirstPublished"]]Elementwise[LessEqualThan[Entity["Person", "ErnestHemingway::8gktg"]["DeathDate"]]][dates]//CountsProperties & Relations (6)
Elementwise threads like Listable functions:
Elementwise[f][1, {2, 3}, {{4, 5, 6}, {7, 8, 9}}]Block[{f},
SetAttributes[f, Listable];
f[1, {2, 3}, {{4, 5, 6}, {7, 8, 9}}]
]%% === %Elementwise[f][] returns f[]:
Elementwise[f][]Elementwise[f][{}] returns {}:
Elementwise[f][{}]For several lists of the same length, Elementwise[f][list1,list2,…] is equivalent to MapThread[f][{list1,list2,…}]:
Elementwise[f][{a, b}, {1, 2}, {x, y}]MapThread[f][{{a, b}, {1, 2}, {x, y}}]If any of the lists contains sublists, Elementwise will thread as much as possible:
Elementwise[f][{{a}, {b}}, {1, 2}, {x, y}]MapThread[f][{{{a}, {b}}, {1, 2}, {x, y}}]Another difference is that Elementwise can thread with scalars:
Elementwise[f][{a, b}, 0, {x, y}]Elementwise[f][list,scalar] is equivalent to Thread[f[list,scalar]] if f[list,scalar] does not evaluate:
Elementwise[f][{a, b, c}, x]Thread[f[{a, b, c}, x]]Some functionality of Elementwise can be obtained with Map:
Elementwise[Max][{1, -1, 3, -4, 5}, 0]Map[Max[#, 0]&, {1, -1, 3, -4, 5}]Or Thread:
Elementwise[LessThan[1]][{1, 0, 2, -1}]Thread[LessThan[1][{1, 0, 2, -1}]]Or a combination of Map and Thread:
Elementwise[f][{{1, 2, 3}, {4, 5, 6}}, {a, b}]MapThread[Thread[f[#1, #2]]&, {{{1, 2, 3}, {4, 5, 6}}, {a, b}}]Elementwise is equivalent to MapAt with All at all applicable levels:
data = {{0.2, 0.8, .9}, {0.12, .74}, {.4}, {.32, .85}};Elementwise[f][data]MapAt[f, data, {All, All}]Related Guides
History
Text
Wolfram Research (2025), Elementwise, Wolfram Language function, https://reference.wolfram.com/language/ref/Elementwise.html.
CMS
Wolfram Language. 2025. "Elementwise." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Elementwise.html.
APA
Wolfram Language. (2025). Elementwise. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Elementwise.html
BibTeX
@misc{reference.wolfram_2026_elementwise, author="Wolfram Research", title="{Elementwise}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Elementwise.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_elementwise, organization={Wolfram Research}, title={Elementwise}, year={2025}, url={https://reference.wolfram.com/language/ref/Elementwise.html}, note=[Accessed: 13-June-2026]}