rotate: Rotate Elements

View source: R/rotate.R

rotateR Documentation

Rotate Elements

Description

Rotate all elements n steps to the right. If n is negative, rotate to the left.

Usage

rotate(x, n = 1L)

ref_rotate(x, n = 1L)

## S3 method for class 'Deque'
rotate(x, n = 1L)

## S3 method for class 'Deque'
ref_rotate(x, n = 1L)

Arguments

x

any R object.

n

integer number of steps to rotate

Details

While rotate uses copy semantics, ref_rotate works by reference, that is, rotates in place on the original object.

Value

For Deque returns the rotated Deque() object.

Examples

d = deque(1, 2, 3, 4)
rotate(d)
rotate(d, n = 2)

container documentation built on Dec. 11, 2022, 5:19 p.m.