Array Roll

Roll an array to left or right by a number of steps.

It’s nearly the same as shifting an array, but with a circular array behavior.

A RollArr module can be used to add endless scroll ability to a step module.

in

The input array to roll

out

The rolled array

roll

  • N=0 : do nothing.
  • N<0 : roll elements to the left and complete the end of the array with the shifted beginning part.
  • N>0 : roll elements to the right and complete the beginning of the array with the shifted end part.