Skip to content

swapMutation<T>(values, first, second): readonly T[]

Defined in: packages/evolution/src/permutation.ts:57

Swap two indexed values in a new array. Index order is unrestricted and equal indices are a fresh-array no-op. Runs in O(n) time and space and never mutates the input.

T

readonly T[]

number

number

readonly T[]

With code INVALID_PERMUTATION when values is not an array or INVALID_INDEX when either index is not a safe integer inside it.