I have many lists that I would like to RotateLeft, but i want the last element to be 0 (rather than the initial first element).
My starting list is:
listA1 = {1, 2, 3}
listA2 = {2, 3, 4}
listB1 = {4, 5, 6}
listB2 = {3, 5, 7}
listC1 = {1, 2, 6}
listC2 = {5, 4, 3}
nestedList = {{listA1, listA2}, {listB1, listB2}, {listC1, listC2}}
{{{1, 2, 3}, {2, 3, 4}}, {{4, 5, 6}, {3, 5, 7}}, {{1, 2, 6}, {5, 4, 3}}}
And my desired output is:
{{{2, 3, 0}, {3, 4, 0}}, {{5, 6, 0}, {5, 7, 0}}, {{2, 6, 0}, {4, 3, 0}}}
Using RotateLeft, i get close to the result:
currentOutput = RotateLeft[nestedList, {0, 0, 1}]
{{{2, 3, 1}, {3, 4, 2}}, {{5, 6, 4}, {5, 7, 3}}, {{2, 6, 1}, {4, 3, 5}}}
But the last element in each list is the first element.
Is there a very simple way to either extend my current code or alternatively do it all in one simple step?
ReplacePart[]
:ReplacePart[RotateLeft[{{{1, 2, 3}, {2, 3, 4}}, {{4, 5, 6}, {3, 5, 7}}, {{1, 2, 6}, {5, 4, 3}}}, {0, 0, 1}], {_, _, -1} -> 0]
$\endgroup$