# How to pass pair of parameters in function

I am writing a function with a pair of values {x,y}, I have issues when I apply this function to list such as{{x1,y1},{x2,y1},{x1,y2},{x2,y2}}.

I have tried with:

f[{x_, y_}] := If[Sqrt[x^2 + y^2] < 1., ArcTan[x, y], 0.];


And it only works with f[x,y].

I've also tried to use the pure function with mapping

Map[If[Sqrt[#1^2 + #2^2] < 1., ArcTan[#1, #2], 0.] &, {{0.1, 0.2}}]


Both are not working as expected. I am so confused about the syntax with other programming languages such as Java, C, etc.

What I want actually to pass a single parameter m, and pair of values {x,y} at the same time:

expfun[m_, {x_, y_}] :=
If[Sqrt[x^2 + y^2] > 1., 0.,
Cos[m ArcTan[x, y]] + I Sin[m ArcTan[x, y]];
SetAttributes[expfun, Listable];


It's not working with e.g:

expfun[2, {{0.1, 0.2}, {0.2, 0.1}}]

• is this what you want? expfun[x_, y_] := Block[{m = 2}, If[Sqrt[x^2 + y^2] > 1., 0., Cos[m ArcTan[x, y]] + I Sin[m ArcTan[x, y]]]]; expfun @@@ {{0.1, 0.2}, {0.2, 0.1}} – user49047 Oct 1 at 14:20
• It should work, f[{x_, y_}] := x + y, f[{1, 2}] -> 3. What do you mean by "it only works with f[x,y]"? – Rohit Namjoshi Oct 1 at 14:24
• Perhaps you want expfun[2,#]&/@{{0.1,0.2},{0.2,0.1}}? – Somos Oct 2 at 11:59

Try this:

f[m_Real, lst_List] :=
Map[If[Sqrt[#[]^2 + #[]^2] > 1., Table[0, Length[lst]],
Cos[m ArcTan[#[], #[]]] +
I Sin[m ArcTan[#[], #[]]]] &, lst]


Let us check it:

f[2., {{0.1, 0.2}, {0.2, 0.1}}]

(* {-0.6 + 0.8 I, 0.6 + 0.8 I}  *)


and

f[2., {{1, 2}, {2, 1}}]
(* {{0, 0}, {0, 0}}  *)


Have fun!