# How to convert list of variables x1, x2, x3 ,x4 ... x10 to list of x1_,x2_,x3_..x10_?

I'm writing a function where I need to give many inputs. I created a list of variables from Table function.

My aim is to get

f[Subscript[x, 1],Subscript[x, 2],Subscript[x, 3]]


from table which i create

Table[Subscript[x, i], {i, 1, 3}]


What i need is

f @@ Blank /@ {Subscript[x, 1],
Subscript[x, 2], Subscript[x, 3],
Subscript[x, 4], Subscript[x, 5],
Subscript[x, 6], Subscript[x, 7],
Subscript[x, 8], Subscript[x, 9],
Subscript[x, 10]}


But that is not converting x to x_ . How to get that ?

• try f @@ (Pattern[#, Blank[]] & /@ {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]}) and see this q/a
– kglr
Commented Oct 6, 2019 at 16:40
• hi, my aim is to convert all elements in the list {x1,x2,x3,x4} to {x1_,x2_,x3_,x4_} so that i can send this list to function f[x1_,x2_,x3_,x4_] = Sin[x1 x2 x3 x4] Commented Oct 7, 2019 at 5:13
• I tried what you suggested it is not converting x to x_ Commented Oct 7, 2019 at 5:13
• Guammala, try symbols = Array[Symbol["x" <> ToString@#] &, 5]; ClearAll[f]; f[## & @@ (Pattern[#, Blank[]] & /@ symbols)] := Evaluate[Sin[Times @@ symbols]]; f[a, b, c, d, e]
– kglr
Commented Oct 7, 2019 at 5:39

Clear[f, lhs, rhs]

{lhs, rhs} = Transpose@ToExpression[
{StringJoin["x", #, "_"], StringJoin["x", #]} & /@
Array[ToString, 4]];

Evaluate[f @@ lhs] := Evaluate[Sin[Times @@ rhs]]

f[a, b, c, d]

(*  Sin[a b c d]  *)

symbols = Array[Symbol["x" <> ToString@#] &, 5];

ClearAll[f];
f[## & @@ (Pattern[#, Blank[]] & /@ symbols)] := Evaluate[Sin[Times @@ symbols]];

f[a, b, c, d, e]


Sin[a b c d e]

f @@ {a, b, c, d, e}


Sin[a b c d e]