Samples values from an array.
If amount is less or equal to 1, it's treated as a percentage to sample. Otherwise it's treated as every _n_th value to sample.
amount
Array to sample
Amount, given as a percentage (0..1) or the number of interval (ie 3 for every third item)
By percentage - get half of the items
const list = [1,2,3,4,5,6,7,8,9,10];const sub = Arrays.sample(list, 0.5);// Yields: [2, 4, 6, 8, 10] Copy
const list = [1,2,3,4,5,6,7,8,9,10];const sub = Arrays.sample(list, 0.5);// Yields: [2, 4, 6, 8, 10]
By steps - every third value
const list = [1,2,3,4,5,6,7,8,9,10];const sub = Arrays.sample(list, 3);// Yields:// [3, 6, 9] Copy
const list = [1,2,3,4,5,6,7,8,9,10];const sub = Arrays.sample(list, 3);// Yields:// [3, 6, 9]
Samples values from an array.
If
amount
is less or equal to 1, it's treated as a percentage to sample. Otherwise it's treated as every _n_th value to sample.