The two following codes work similarly:
Num = 5;
symbols = Hold[X1, X2, X3, X4, X5];
or
Num = 5;
Xlists= StringJoin["X", #] & /@ Array[ToString, Num];
symbols = Hold[Xlists[[1]], Xlists[[2]], Xlists[[3]], Xlists[[4]], Xlists[[5]]];
Question:
When
Num
is large (for instanceNum=200
), I would not like to use the stupid way: write all theX1, X2, ..., X200
in theHold[]
.I wonder whether there are something like
Hold[Xlists]
for such problem. Well, I tried different ways but failed.
Thank you very much in advance!
Edit2:
Num=5;
data = {{0, 0, 0}, {1, 2, 3}, {2, 3, 4}, {4, 5, 6}, {0, 1, 2}};
For[ii = 1, ii <= Num, ii++,
symbols[[{ii}]] /. _[x_] :> (x = data[[ii]])
];
I know that the X1,X2,...X5
will have certain values such as X1
will be {0,0,0}
. Then it seems that I cannot get the symbol X1
using the way symbols[[1]]
because it will return {0,0,0}
not X1
(except I directly write as X1
).
So after giving values to X1,X2,..., how can I can the it form symbols
instead of directly using X1,X2,...
Thank you!
X1=12345
, what behavior is desired?Hold[X1, X2, X3, X4, X5]
, orHold[12345, X2, X3, X4, X5]
? $\endgroup$DumpSave
for storing with the related symbol. SinceDumpSave
doesn't work for something likelist[[1]]
. $\endgroup$Hold @@ (Symbol["X" <> ToString@#] & /@ Range[5])
? $\endgroup$