# Elementary operations on list of points [closed]

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.

• If alist = {{x1, y1}, {x2, y2}, {x3, y3}};, then f @@@ alist will do this. Or the more verbose way is to do: Map[Apply@f, alist, {1}].
– Syed
Feb 1 at 15:03
• f /@ points if f takes a list e.g f[{x,y}], otherwise just f@@@points. This is all covered in the documentation so I'm voting to close. If you want to also pass an index, then use MapIndexed. Feb 1 at 15:11
• #1^i #2^j & @@@ {{x1, y1}, {x2, y2}, {x3, y3}}
– Syed
Feb 1 at 15:21
• I’m voting to close this question because the OP needs to spend time learning the tool and show minimal knowledge of Mathematica before posting questions. I also wish the OP good luck.
– Syed
Feb 1 at 15:23

Clear["Global*"]


Format indexed variables as subscripts

(Format[#[n_]] := Subscript[#, n]) & /@ {x, y};

pts = Array[{x[#], y[#]} &, 5] Map

f /@ pts ex1 = #[]^i*#[]^j & /@ pts MapApply

f @@@ pts ex2 = #1^i*#2^j & @@@ pts ex1 === ex2

(* True *)

• Thank you. This is informative. Feb 1 at 21:43

Another approach (which I learned from this post by bmf) is to use ArrayReduce

m = Array[{Subscript[x, #],Subscript[y,#]} &, 5]

{{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4 }, {x5, y5}}
ArrayReduce[f, m, 2]

{f[{x1, y1}], f[{x2, y2}], f[{x3, y3}], f[{x4, y4}], f[{x5, y6}]} 
ArrayReduce[Times@@{#[]^i,#[]^j}&, m,2] • Thank you. I liked this approach too. Feb 1 at 21:44
• (+1) I am very glad to see that ArrayReduce` is gaining popularity!
– bmf
Feb 2 at 0:24