rotate

rotate(w, theta)

rotate(w, theta, v)

Try it yourself:


rotate(): Rotating Collection Elements

rotate() cyclically moves entries in an array or matrix dimension. It is useful for circular buffers, periodic patterns, and shifting a sequence without losing elements.

Wraparound behavior

A positive or negative offset determines direction, while entries that leave one end reappear at the other. This differs from resize(), which can discard or add positions. Check the shape with size() and choose the intended dimension explicitly.

For one directional shift, compare results with leftShift() only conceptually: bit shifts alter binary digits, whereas rotate rearranges collection values. Use row() or column() to inspect matrix slices.

Try Rotate in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions