MCPcopy Create free account
hub / github.com/denoland/std / combos

Function combos

dotenv/stringify_test.ts:111–119  ·  view source on GitHub ↗
(arr: T[], k: number)

Source from the content-addressed store, hash-verified

109 ];
110
111 function combos<T>(arr: T[], k: number): T[][] {
112 if (k === 0) return [[]];
113 if (arr.length < k) return [];
114 const [first, ...rest] = arr;
115 return [
116 ...combos(rest, k - 1).map((c) => [first!, ...c]),
117 ...combos(rest, k),
118 ];
119 }
120
121 for (const k of [1, 2, 3]) {
122 for (const c of combos(trickyChars, k)) {

Callers 1

stringify_test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected