How do I assign a value, say 7 or "t", to a[1, 2][[3]]?
a[1, 2][[3]] = 7
and
a[1, 2][[3]] = "t"
both give
Set::setps: a[1,2] in the part assignment is not a symbol
I have looked here and here, but both questions ask more complicated questions and I'm afraid I'm none the wiser.
a[1,2][3]? – Lukas Lang Sep 09 '17 at 18:50a[1, 2] = MapAt[7 &, a[1, 2], {3}]ora[1,2] = ReplacePart[a[1, 2], 3 -> 7]? – kglr Sep 09 '17 at 18:55MapAtorRepalcePartwill reassign entire list. Note also thata[1,2][3]is a completely different thing - it is a nested indexed variable, whilea[1,2][[3]]is a part3of the value of indexed variablea[1,2]. – Leonid Shifrin Sep 09 '17 at 18:56DownValuesorSubValues), which are rule-based. This is why this kind of complex part assignments are not allowed there. You can use an association instead, where you will be able to do something similar to what you want. – Leonid Shifrin Sep 09 '17 at 19:01a[[1,2,3]]=7- is this what you're after? – Lukas Lang Sep 09 '17 at 19:07a[1,2,3]=7appears to do the trick.a[[1,2,3]]=7givesSet::noval: Symbol a in part assignment does not have an immediate value. – Sep 09 '17 at 19:11a[1,2,3] = 7, you don't define an array. Instead, you define an indexed variable. They are different objects. To define an array, you need to useList, likea = {{{1,2,3}, {4,5,6}}, {{7,8,9},{10,11,12}}}, which is a 3D array. Then you can doa[[1,2,3]] = 7, and that would replace the number6in that array by7. But you must have an array stored in some variable first, to make such part assignments. – Leonid Shifrin Sep 09 '17 at 19:15aaListwith three levels. – Marius Ladegård Meyer Sep 09 '17 at 19:53