Package: alexandria

Function rotate

Lambda List

rotate (sequence &optional n)

Details

Returns a sequence of the same type as sequence, with the elements of sequence rotated by n. n elements are moved from the end of sequence to the front if n is positive, and -n elements moved from the front to the end if n is negative.

sequence must be a proper sequence. n must be an integer. The default value is 1.

If the absolute value of n is greater then the length of sequence, the results are identical to calling rotate with (* (signum n) (mod n (length sequence))).

Notes

The original sequence may be destructively altered, and the result sequence may share structure with it.