The list having permutations.
expect(permutations(empty())).toStrictEqual(empty());
const subSeq = permutations(range(1, 5));
const sequences = toArray(subSeq).map((seq) => toArray(seq));
expect(sequences).toStrictEqual([
[1, 2, 3, 4],
[2, 1, 3, 4],
[3, 2, 1, 4],
[2, 3, 1, 4],
[3, 1, 2, 4],
[1, 3, 2, 4],
[4, 3, 2, 1],
[3, 4, 2, 1],
[3, 2, 4, 1],
[4, 2, 3, 1],
[2, 4, 3, 1],
[2, 3, 4, 1],
[4, 1, 2, 3],
[1, 4, 2, 3],
[1, 2, 4, 3],
[4, 2, 1, 3],
[2, 4, 1, 3],
[2, 1, 4, 3],
[4, 1, 3, 2],
[1, 4, 3, 2],
[1, 3, 4, 2],
[4, 3, 1, 2],
[3, 4, 1, 2],
[3, 1, 4, 2],
]);
Creates permutations of the list.