All symbolic entries of the array cArr should be set to 0, i.e. c(i)=0 for all i. Later they should be set to 7, i.e. c(i)=7 for all i. Desired effect: within the Do -loop I need to access individual entries like c(3) to be 0, and later to be 7, and then looped.
In[1]:= Do[
Clear[c];
cArr = Array[c, 4];(* out--> {c[1],c[2],c[3],c[4]}*)
Evaluate[cArr] = ConstantArray[0, 4];(* all c[i] = 0 *)
Clear[c];
Evaluate[cArr] = ConstantArray[7, 4]; (* all c[i] = 7 *)
, 3] (*looping can return unexpected error message*)
The above suggested code produces the desired effect, okay. But is there any more elegant coding style to get the desired effect? For less complexity, I could get rid of the placeholder name cArr, sure. In any case, the use of Clear and Evaluate seems awkward. I can't complain, all c(i) are 0, later they all are 7, and the looping doesn't return any error message, as desired.
In[2]:= Definition[cArr]
Out[2]= "cArr = {c[1], c[2], c[3], c[4]}"
In[3]:= cArr
Out[3]= {7, 7, 7, 7}
In[4]:= {c[3], c[5]}
Out[4]= {7, c[5]}