I noticed that "ReplacePart" can use pattern. For example:
ReplacePart[{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {i_, i_} -> x]
{{x, 0, 0}, {0, x, 0}, {0, 0, x}}
So I naively think I can do a little change like
ReplacePart[{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {i_+1, i_} -> x]
But it gives
{x, x, x}
Why? I anticipated that the result whould be
{{0, 0, 0}, {x,0,0}, {0, x, 0}}
Can anyone help?
Comments
Post a Comment