/array/shift
stdShifts the given array to the left and circulates the elements back by modulo of the array's length.
Type signature
(count: number) => <T>(xs: T[]) => T[]
Examples
shift(1)([1, 2, 3, 4, 5]);
// ⇒ [2, 3, 4, 5, 1]
Try in REPL
shift(2)([1, 2, 3, 4, 5]);
// ⇒ [3, 4, 5, 1, 2]
Try in REPL
shift(3)([1, 2, 3, 4, 5]);
// ⇒ [4, 5, 1, 2, 3]
Try in REPL
Questions
- How to shift an array?