Skip to content

@lelantos-org/sdk / core / shuffled

Function: shuffled() โ€‹

ts
function shuffled<T>(items, pick?): T[];

Defined in: @lelantos-org/sdk/dist/core/random.d.ts:47

A uniformly random permutation of items, as a new array.

Fisherโ€“Yates, downwards, so every one of the n! orderings is equally likely โ€” given an unbiased pick, which is why the default is randomBelow and not a scaled float.

pick(k) must return a uniform integer in [0, k); injecting one is how a test pins a specific permutation.

Type Parameters โ€‹

Type Parameter
T

Parameters โ€‹

ParameterType
itemsreadonly T[]
pick?(n) => number

Returns โ€‹

T[]

Lelantosno cookies ๐Ÿช ยท no tracking ๐Ÿ‘๏ธ ยท no accounts ๐Ÿ‘คwalletexplorer4536080GitHub