MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / combinations

Function combinations

src/compute-engine/boxed-expression/match.ts:1336–1352  ·  view source on GitHub ↗

Generate all combinations of `k` indices from `0..n-1`

(n: number, k: number)

Source from the content-addressed store, hash-verified

1334
1335 result =
1336 capture === null
1337 ? null
1338 : matchRemaining(
1339 patterns.slice(nextAppPatternIndex),
1340 capture
1341 );
1342
1343 // A complete overall match with this sequence capturing 'j' operands.
1344 if (result) break;
1345
1346 // No match: restore the shared ops array to its exact
1347 // pre-attempt state.
1348 ops.length = 0;
1349 ops.push(...savedOps);
1350
1351 j++;
1352 if (j >= ops.length) break;
1353
1354 // If the next pattern matches yet another/subsequent operand, move to the next
1355 // iteration and try to match remaining patterns.

Callers 1

matchWithMissingTermsFunction · 0.70

Calls 1

backtrackFunction · 0.85

Tested by

no test coverage detected