I tried to override the Subscript
operator to make matrix indexing a bit more "user-friendly" in complex expressions with the following code according to the documentation:
Subscript[x__] := Part[x]; (* Indexed instead of Part has the same effect *)
I defined matrix X3×2 as X = Range[10, 15]~Partition~2;
.
Now, I assign this matrix as the first element of an a
list and I prepend a full-one-row to it. I execute these two commands four times:
a = {X};
PrependTo[Subscript[a, 1], ConstantArray[1, 2]];
After 4 executions of this cell I get the following dimensions:
Dimensions[Subscript[a, 1]] (* {7, 2} *)
Dimensions[Part[a, 1]] (* {3, 2} *)
When I print out the matrices I get two distinct ones:
Part[a, 1]
(* {{10, 11}, {12, 13}, {14, 15}} *)
Subscript[a, 1]
(* {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {10, 11}, {12, 13}, {14, 15}} *)
I reset a
to {X}
on every iteration, despite of this I see {1, 1}
prepended four times into the a1 matrix. My question is why this happens?