I have a very complex code in which I assign a value to an element of an array and then I reassign to it another one. A minimal example:
Clear[ggg];
t = {1, 2, 3};
s = {2, 5, 6};
Evaluate[ggg @@ t ] = 1;
Evaluate[ggg @@ s] = 2;
Evaluate[ggg @@ t ] = -1;
Evaluate[ggg @@ s] = 3;
and the error is
Set::setraw: Cannot assign to raw object 1.
Set::setraw: Cannot assign to raw object 2.
A solution may be to use Condition or If, but does there exist a command to force the new assignment?
ClearAll[t,s]
before making new assignments? $\endgroup$ggg[Sequence @@ t] = -1; ggg[Sequence @@ s] = 3;
. But I suspect that you'll want to do things a little more naturally, like makeggg
aList
rather than assign itDownValues
as you are doing. $\endgroup$Evaluate[ggg@@t]=-1
, the left hand side ofSet
evaluates to1
because you have already given it that value with the previous evaluations.Set
rightly complains that it can't assign a value of-1
to1
. $\endgroup$