Skip to main content

list manipulation - Part not behaving the way I expect it to


p = {{1, 0, 0}, {0, 1, 0}, {0, 1, 0}};
p[[All, 3]][[1 ;; 2]] = {1, 1};
p

I want to replace the first two elements of the third column of a 3x3 identity matrix.


The above code does not work. I get a depth-error message.



Set::partd: Part specification is longer than depth of object




I am confused because the following code is functional.


p[[All, 3]][[1 ;; 2]]


Comments