Skip to the content

Tane種

Reproduce numbers from a seed, shuffle or pick items, share a daily puzzle and resume a saved stream.

Tane means seed in Japanese. About the name

Contents

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

NameTypeDescription
randomRandom

A random source returning values in [0, 1).

countnumber

The number of items or draws requested.

limitnumber

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)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tane 1.3.0.