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

Function countMatchingElements

src/compute-engine/library/sets.ts:1563–1574  ·  view source on GitHub ↗
(
  expr: Expression,
  filter: (elem: Expression) => boolean
)

Source from the content-addressed store, hash-verified

1561 // Three-valued: `x ∈ col ∧ x ∉ s1 ∧ x ∉ s2 ∧ …` with Kleene
1562 // combination — indeterminate member tests yield `undefined`, not a
1563 // spurious definitive answer.
1564 contains: (expr, x) => {
1565 if (!isFunction(expr)) return undefined;
1566 const [col, ...others] = expr.ops;
1567 return kleeneAnd([
1568 col.contains(x),
1569 ...others.map((set) => kleeneNot(set.contains(x))),
1570 ]);
1571 },
1572 count: (expr) => differenceCount(expr, memberOf),
1573 // Finite when the first set is finite, whatever the other sets are.
1574 isFinite: (expr) => {
1575 if (!isFunction(expr)) return undefined;
1576 if (expr.ops[0]?.isFiniteCollection === true) return true;
1577 const count = differenceCount(expr, memberOf);

Callers 1

sets.tsFile · 0.85

Calls 3

isFunctionFunction · 0.90
eachMethod · 0.65
filterFunction · 0.50

Tested by

no test coverage detected