# 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.

## closed as off-topic by MarcoB, m_goldberg, Alex Trounev, Carl Lange, eyorbleApr 8 at 17:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, Alex Trounev, Carl Lange, eyorble
If this question can be reworded to fit the rules in the help center, please edit the question.

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 at 12:34
• @Bran it gives exactly what you asked for, f[x1, x2, x3, y1, y2, y3]... – Kuba Apr 2 at 12:35
• @Bran I'm not understand. They are! Try it, pls. – Slepecky Mamut Apr 2 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 at 12:39
• @Bran f[whatever, ##, whatever2]& @@ ... – Kuba Apr 2 at 12:44