Exchanges two values.
npm install @extra-array/swap.minExchanges two values.
:package:
:smiley_cat:
:running:
:vhs:
:moon:
:scroll:
:newspaper:
:blue_book:
> Alternatives: [swap], [swap$].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
> This is browserified, minified version of [@extra-array/swap].
> It is exported as global variable array_swap.
> CDN: [unpkg], [jsDelivr].
[@extra-array/swap]: https://www.npmjs.com/package/@extra-array/swap
[unpkg]: https://unpkg.com/@extra-array/swap.min
[jsDelivr]: https://cdn.jsdelivr.net/npm/@extra-array/swap.min
``javascript`
array.swap(x, i, j);
// x: an array
// i: an index
// j: another index
`javascript
const array = require("extra-array");
var x = [1, 2, 3, 4];
array.swap(x, 0, 1);
// [ 2, 1, 3, 4 ]
array.swap(x, 0, 3);
// [ 4, 2, 3, 1 ]
``
- List-Extra.swapAt: elm
- Collections.swap: Java)
- pure-swap: @alferov
[swap]: https://github.com/nodef/extra-array/wiki/swap
[swap$]: https://github.com/nodef/extra-array/wiki/swap$