Reference · Streams, draws and seeds
distinctBelowfunction
count different integers below limit, in the order drawn, by drawing
again whenever a number comes up twice. The draw count therefore depends on
the luck of the stream; prefer sample for new code, and keep this where a
stored seed already depends on it.
Import it
import { distinctBelow } from "@johnmorrisdotca/tane";
Definition
function distinctBelow(random: Random, count: number, limit: number): number[]
Parameters
| Name | Type | Description |
|---|---|---|
random | Random | A random source returning values in [0, 1). |
count | number | The number of items or draws requested. |
limit | number | The exclusive upper bound for distinct integer draws. |
Returns
number[]
count different integers below limit, in the order drawn, by drawing again whenever a number comes up twice. The draw count therefore depends on the luck of the stream; prefer sample for new code, and keep this where a stored seed already depends on it.
Examples
import { distinctBelow, mulberry32 } from "@johnmorrisdotca/tane";
const random = mulberry32(42);
console.log(distinctBelow(random, 3, 10));[ 6, 4, 8 ]What it prints (run when this page was built)