-
Notifications
You must be signed in to change notification settings - Fork 5
randomPrefix
Subhajit Sahu edited this page Dec 8, 2022
·
2 revisions
Pick an arbitrary prefix.
Similar: randomPrefix, prefixes, hasPrefix.
function randomPrefix(x, n, fr)
// x: an array
// n: number of values [-1 ⇒ any]
// fr: random number generator ([0, 1))
const xarray = require('extra-array');
var x = [1, 2, 3];
xarray.randomPrefix(x);
// → [ 1, 2 ]
xarray.randomPrefix(x, 1);
// → [ 1 ]
xarray.randomPrefix(x, -1);
// → [ 1, 2 ]