each
Each
f'y
x f'y
x f'y
each, also known as map, is used to apply a function to all elements of an array y
.
When given two arguments and dyadic f
, acts as a zip or each dyad adverb, applying f
between each element of x
and y
. The two arrays must be equal in length.
If x
is an atom, it will be repeated for each element in y
.
{2*x}'5 7 2 10 14 4 1 2 3{x,y}'3 4 5 (1 3 2 4 3 5) (5),'1 3 4 (5 1 5 3 5 4)
Each generalizes to multiple arguments and n-adic functions:
{x+y-z}'[1 2 3;4 5 6;7 8 9] -2 -1 0