# Populating function inputs from lists [closed]

I have several lists containing variables, e.g. list1={x1,x2,x3}, list2={y1,y2,y3}, etc. I would like to define a function in those variables, i.e. f[x1,x2,x3,y1,y2,y3]. I have tried to use Do and AppendTo but this seems to reset f at every iteration. Any help is appreciated.

f@@(list1 ~Join~ list2)


Or, more generally, use @@ to "open" the structure of List:

list1 = {x1, x2, x3}; list2 = {y1, y2, y3};
f @@ (list1~Join~list2)


f[x1, x2, x3, y1, y2, y3]

For a list of lists:

listOflists = {list1, list2}
f @@ (Flatten@listOflists)


f[x1, x2, x3, y1, y2, y3]

• Yes, it does. Thanks. I will accept your answer. – Bran Apr 2 '19 at 12:34
• @Bran it gives exactly what you asked for, f[x1, x2, x3, y1, y2, y3]... – Kuba Apr 2 '19 at 12:35
• @Bran I'm not understand. They are! Try it, pls. – Slepecky Mamut Apr 2 '19 at 12:36
• @SlepeckyMamut How can I add more variables to the function not from a list? Like f[z1,z2,x1,x2,x3,y1,y2,y3]. – Bran Apr 2 '19 at 12:39
• @Bran f[whatever, ##, whatever2]& @@ ... – Kuba Apr 2 '19 at 12:44