I have a list of points $$L = \{\{x_1,y_1\}, \{x_2,y_2\}, \{x_3,y_3\},\cdots\{x_n,y_n\}\}$$ and I want to create a list $$L1 = \{f(x_1,y_1), f(x_2,y_2), \cdots, f(x_n,y_n)\},$$ where $f$ is some function. Let us take the example $f(x,y) = x^i y^j.$
Is there a simple direct method? In my example, would it be possible to get the list $\{x_1^iy_1^j, x_2^iy_2^j,\cdots x_n^iy_n^j\}$ directly without defining $f(x,y) = x^i y^j$?
This might be a trivial question, but not for people who used to use Python.
alist = {{x1, y1}, {x2, y2}, {x3, y3}};
, thenf @@@ alist
will do this. Or the more verbose way is to do:Map[Apply@f, alist, {1}]
. $\endgroup$f /@ points
if f takes a list e.gf[{x,y}]
, otherwise justf@@@points
. This is all covered in the documentation so I'm voting to close. If you want to also pass an index, then useMapIndexed
. $\endgroup$#1^i #2^j & @@@ {{x1, y1}, {x2, y2}, {x3, y3}}
$\endgroup$