rotate - rotate elements of an array along an axis
arr.rotate(num)
arr.rotate(num,
axis)
The rotate() method rotates the elements of an
array along the specified axis. The elements are shifted by
num positions. Elements shifted off one end of the axis are
wrapped around to the other end. This is similar to APL num
⊖ arr and num
⌽[axis]
arr.
A positive num rotates elements towards higher indices, while a negative num rotates towards lower indices.
The axis parameter is an axis specification. If omitted, it defaults to the last axis (-1).
A new array of the same shape and type as arr, with its elements rotated.
TypeCheck if arr is not an array, or if
num or axis is not an integer
ArgCheck if an incorrect number of arguments is
given
RangeCheck if axis is not a
valid axis of arr
arr = 5->iterate()
arr
0 1 2 3 4
arr.rotate(1)
4 0 1 2 3
arr.rotate(-1)
1 2 3 4 0
a = [2, 3].iterate()
a
0 1 2
3 4 5
a.rotate(1, 0)
3 4 5
0 1 2
a.rotate(1, 1)
2 0 1
5 3 4