subset
subset<
T>(items,p):T[]
Defined in: src/global/collections.ts:266
Each element kept independently with probability p.
The result has no fixed length: it is a coin flip per element, so the size
varies around items.length * p. Order is preserved.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Collection<T>
number
Returns
Section titled “Returns”T[]
Example
Section titled “Example”subset([1, 2, 3, 4, 5, 6], 0.5); // [ 1, 4, 5 ]