Skip to content

Commit 2388683

Browse files
authored
Merge pull request #4 from N8Brooks/optional_permutations_r
fix(permutations): allow r to not be passed
2 parents 21ddd6d + db55a32 commit 2388683

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

permutations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
export function* permutations<T>(
2323
iterable: Iterable<T>,
24-
r: number | undefined,
24+
r?: number,
2525
): Generator<T[]> {
2626
const pool = Array.from(iterable);
2727
const n = pool.length;

permutations_test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ Deno.test("n = r", () => {
7676
});
7777

7878
Deno.test("r = undefined (0)", () => {
79-
const actual = [...permutations("", undefined)];
79+
const actual = [...permutations("")];
8080
assertEquals(actual, [[]]);
8181
});
8282

8383
Deno.test("r = undefined (n)", () => {
84-
const actual = [...permutations("abc", undefined)];
84+
const actual = [...permutations("abc")];
8585
const expected = [
8686
["a", "b", "c"],
8787
["a", "c", "b"],

0 commit comments

Comments
 (0)