Reference · Rules, solvers and generation
shuffledfunction
A copy of the list in a random order (Fisher–Yates); the list given is left alone.
Import it
import { shuffled } from "@johnmorrisdotca/tsunagi";
Definition
function shuffled<T>(items: readonly T[], random: Random): T[]
Parameters
| Name | Type | Description |
|---|---|---|
items | readonly T[] | The items to copy and shuffle. |
random | Random | A reproducible random source returning values in [0,1). |
Returns
T[]
A copy of the list in a random order (Fisher–Yates); the list given is left alone.
Examples
import { seededRandom, shuffled } from "@johnmorrisdotca/tsunagi";
console.log(shuffled(["A","B","C"],seededRandom(42)));[ 'C', 'A', 'B' ]What it prints (run when this page was built)