I have an association of the following form :
assoc = Association[a -> {1, 2, 3}, b -> {5, 6, 7}]
<|a -> {1, 2, 3}, b -> {5, 6, 7}|>
(the size of actual lists in assoc is 30).
If I want to change the value of the list associated to a in the following manner: assoc[a][[1]] = 2
, it does not work. I understand why mostly, I have looked it up (some mutability stuff e_e) !
by searching the forum, I didn't find any better than:
temp=assoc[a]
temp[[1]]=2
AssociateTo[assoc,a->temp]
I have two questions :
Between changing in place the value of a very big list (very) or changing the value of a very big association like demonstrated above, which is faster ?
Second, is there a better way to change the value of elements of the list associated to key a in assoc ?i.e. without the copying process.
Thank you.
Part
call and wrap the key(s) inKey
:assoc[[Key[a], 1]] = 2
$\endgroup$