question is as follows
define a list
ttt={1,2};
and if I set values in this way
{ttt[[1]],ttt[[2]]}={3,4}
then the value of list ttt now becomes {3,4}
Now I try this
f:={ttt[[1]],ttt[[2]]}
then ?f
will show that f:={tmp[[1]],tmp[[2]]}
then if I just write
f={3,4}
this will not affect the values of list ttt .
the question is that I want the values of list ttt changes as well when I set values to f. How to do this?
More Question!!
why the following code didn't change the value of ttt??
Table[With[{i = i}, Defer@ttt[[i]]], {i, 1, 2}] = {111, 222}
while
Table[With[{i = i}, Defer@ttt[[i]]], {i, 1, 2}]
really gives
{ttt[[1]],ttt[[2]]}
ttt[[3]]=val
) only works, if the list part is at the left hand side of theSet
operator (asSet
has attributeHoldFirst
), otherwise it simply returns the appropriate element ofttt
. $\endgroup$ttt
change whenf
changes by usingSetDelayed
, as inttt:=f
. But it sounds like you are trying to do this at the same time as you setf:=ttt
. You can't do both at once because it creates a circle (you will get a recursion error). $\endgroup$