-
Notifications
You must be signed in to change notification settings - Fork 5
rotate
Subhajit Sahu edited this page Jun 20, 2020
·
23 revisions
Rotates values in array. 🏃 📼 📦 🌔 📒
Alternatives: rotate, rotate$.
Similar: [repeat], [cycle], rotate, [reverse].
array.rotate(x, [n]);
// x: an array
// n: rotate amount (+ve: left, -ve: right)
const array = require('extra-array');
var x = [1, 2, 3, 4];
array.rotate(x, 1);
// [ 2, 3, 4, 1 ]
array.rotate(x, 2);
// [ 3, 4, 1, 2 ]
array.rotate(x, -1);
// [ 4, 1, 2, 3 ]