I'd like to display only the variable (indexed variable) name (in symbol form, not in string form) instead of its value in Mathematica. Say I have a variable foo[i]
with i
being the index, How do I get something like {foo[1], foo[2]}
as output?
I have tried i = 1; HoldForm[foo[i]]
but Mathematica seems to hold all evaluations, including replacing the index i
with its value. HoldForm[foo[i]] /. i -> i
also won't work.
There exists another thread in SE that connects with this question, but it doesn't seem to work either.
HoldForm[foo[i]] /. i -> 1
orHoldForm[foo[i]] /. i -> j
will work. $\endgroup$With[{i=1},HoldForm[foo[i]]]
works. As doesi=1;With[{i=i},HoldForm[foo[i]]]
. $\endgroup$