Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@extra-array/permutation-update

nodef83MIT2.10.19TypeScript support: included

Picks an arbitrary permutation.

extra, array, permutation, update, permutation$

readme

Picks an arbitrary permutation. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: permutation, permutation$.
Similar: permutation, permutations, hasPermutation.

This is part of package extra-array.


array.permutation$(x, [n], [r]);
// x: an array (updated)
// n: number of values (-1 => any)
// r: random seed 0->1
// → x
const array = require("extra-array");

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

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

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

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


References