Skip to content

compute circshift

kgryte edited this page May 12, 2015 · 1 revision

Circularly shifts elements/characters. x may be an array or a string. k is an integer specifying the number of positions to shift. The sign of k specifies the shift direction.

compute.circshift( [1,2,3,4,5], 2 );
// returns [4,5,1,2,3]

var str = compute.circshift( 'beepboop', -3 );
// returns 'pboopbee'

Note: if provided an array, the array, is mutated.

Clone this wiki locally