-
Notifications
You must be signed in to change notification settings - Fork 5
swap$
wolfram77 edited this page Apr 11, 2020
·
23 revisions
array.swap$(x, i, j);
// x: an array (updated)
// i: an index
// j: another index
// --> x
const array = require('extra-array');
var x = [1, 2, 3, 4];
array.swap$(x, 0, 1);
// [2, 1, 3, 4]
x;
// [2, 1, 3, 4]
var x = [1, 2, 3, 4];
array.swap$(x, 0, -1);
// [4, 2, 3, 1]
var x = [1, 2, 3, 4];
array.swap$(x, 0, 0);
// [1, 2, 3, 4]