Still learning the fundamentals of the language I would like to ask you what advantages there might be in writing something like:
a[1] = 2;
a[2] = 4;
a[3] = "x";
It seems to me that it is always better to write
a = {2, 4, "x"};
Do you know about any practical constructs where indexed variables would offer an advantage?
Solve[a[1]^2==2, a[1]]
but you can'tSolve[a[[1]]^2==2, a[[1]] ]
. This is what we typically use when we don't know the number of symbolic variables we need beforehand. I would sometimes define a 3 by 3 matrix with explicit symbolic elements asArray[a, {3,3}]
. $\endgroup$