5
$\begingroup$

I'm trying to create a list of functions that is dynamic in size and defines function names like so:

size = 10
functionList = {}
For[i=0;i<10;i++, Append[functionList,xi[t]]]

desired output: functionList = {x1[t], x2[t], x3[t],...,x10[t]}

Is there such a feature in Mathematica?

$\endgroup$
6
$\begingroup$
ClearAll[functionList]
functionList[n_] := Array[Symbol["x" <> ToString[#]][t] &, n]

functionList[10]

{x1[t], x2[t], x3[t], x4[t], x5[t], x6[t], x7[t], x8[t], x9[t], x10[t]}

Also

ClearAll[functionList2]
functionList2[n_] := Through[Array[Symbol["x" <> ToString[#]] &, n] @ t]

functionList2[10]

{x1[t], x2[t], x3[t], x4[t], x5[t], x6[t], x7[t], x8[t], x9[t], x10[t]}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.