本文へ移動

Tane種

シードで同じ数列を再現し、項目を並べ替えたり選んだり、日替わりの問題を共有したり、保存した位置から再開したりできます。

「種」は英語の seed に当たる日本語です。 名前について(英語)

目次

リファレンス · 乱数列・抽選・シード

counted関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A seeded stream that counts its own draws, so that it can be written down at any moment and picked up later: const random = counted(42), draw from it as from any stream, then keep random.position(). The numbers are those of mulberry32(seed), draw for draw.

インポート

import { counted } from "@johnmorrisdotca/tane";

定義

function counted(seed: number, draws?: number): CountedRandom

引数

名前型説明
seednumber

The numeric seed, read as an unsigned 32-bit integer by the stream.

draws (省略可)number

The nonnegative number of draws already consumed.

戻り値

CountedRandom

A seeded stream that counts its own draws, so that it can be written down at any moment and picked up later: const random = counted(42), draw from it as from any stream, then keep random.position(). The numbers are those of mulberry32(seed), draw for draw.

例

import { counted } from "@johnmorrisdotca/tane";

const position = { seed: 42, draws: 3 };
console.log(counted(42, 3).position());
{ seed: 42, draws: 3 }

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/tane 1.3.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。