1
$\begingroup$

I am wondering if it is possible to produce an input such as

x[1],x[2],x[3],...,x[n]

for an arbitrary but fixed amount of n without having to type in every single term by hand. Note that the above is not supposed to be a list, but simply a sequence of variables and commas.

I thought that maybe a conversion of

x[1]+x[2]+x[3]+...+x[n]

to

x[1],x[2],x[3],...,x[n]

could do the trick. Something similar was asked in the question How to replace plus sign by comma but it does not provide the solution I am after, since it produces a list instead of sequence. Is there a convenient way to get such an input sequence in Mathematica? Thanks for any suggestion!

$\endgroup$

closed as off-topic by chuy, Bob Hanlon, MarcoB, Michael E2, Mr.Wizard Jul 17 '15 at 6:03

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." – chuy, Bob Hanlon, MarcoB, Michael E2, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Sequence @@ Table[x[i], {i, 1, n}]? $\endgroup$ – MarcoB Jul 16 '15 at 20:19
  • 3
    $\begingroup$ f[n_] := Sequence @@ x /@ Range[n]? $\endgroup$ – march Jul 16 '15 at 20:20
  • 1
    $\begingroup$ They're basically the same answer, but @MarcoB was first, so if he wants to post an answer, he can! $\endgroup$ – march Jul 16 '15 at 20:32
  • 1
    $\begingroup$ This can actually be done without Sequence too: Fold[D, f[x, y, z], {x, y, z}]. $\endgroup$ – Szabolcs Jul 16 '15 at 20:46
  • 2
    $\begingroup$ How about Array? Array[x, n] or Sequence@@Array[x,n] depending on what you are planning on doing with it. $\endgroup$ – bill s Jul 16 '15 at 23:32