import { permutations } from "https://deno.land/x/combinatorics@1.1.2/mod.ts";
Yields r
length Arrays
from the input iterable
. Order of selection is
important and elements are chosen without replacement. If r
is undefined, then
the length of the iterable
is used.
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { permutations } from "https://deno.land/x/combinatorics/mod.ts";
const sequences = [...permutations([1, 2, 3, 4], 2)];
assertEquals(sequences, [
[1, 2], [1, 3], [1, 4],
[2, 1], [2, 3], [2, 4],
[3, 1], [3, 2], [3, 4],
[4, 1], [4, 2], [4, 3],
]);
Parameters
iterable: Iterable<T>