Skip to main content
Go to Latest
function permutations
import { permutations } from "https://deno.land/std@0.102.0/collections/mod.ts";

Builds all possible orders of all elements in the given array Ignores equality of elements, meaning this will always reutrn the same number of permutations for a given length of input.

Example:

const numbers = [ 1, 2 ]
const windows = permutations(numbers)

console.assert(windows === [
    [ 1, 2 ],
    [ 2, 1 ],
])

Parameters

array: Array<T>

Returns

Array<Array<T>>