Skip to content

rotate$

wolfram77 edited this page Apr 13, 2020 · 25 revisions

Rotates values in array. 🏃 📼 📦 🌔

Alternatives: default, update.

array.rotate$(x, n);
// x: an array (updated)
// n: rotate amount (-ve: left, +ve: right)
// --> x
const array = require('extra-array');

var x = [1, 2, 3, 4];
array.rotate$(x, 1);
// [4, 1, 2, 3]

x;
// [4, 1, 2, 3]

var x = [1, 2, 3, 4];
array.rotate$(x, 2);
// [3, 4, 1, 2]

var x = [1, 2, 3, 4];
array.rotate$(x, -1);
// [2, 3, 4, 1]

references

Clone this wiki locally