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

Function tuples

test/compute-engine/solve-domain.test.ts:27–36  ·  view source on GitHub ↗

Evaluate a multi-variable `Solve` and return its solution tuples as arrays * of numbers, in the (lexicographic) order the engine produced them. Throws if * the result is not a decided `List` of `Tuple`s.

(expr: BoxedExpression)

Source from the content-addressed store, hash-verified

25/** Evaluate a multi-variable `Solve` and return its solution tuples as arrays
26 * of numbers, in the (lexicographic) order the engine produced them. Throws if
27 * the result is not a decided `List` of `Tuple`s. */
28function tuples(expr: BoxedExpression): number[][] {
29 const r = expr.evaluate();
30 if (r.operator !== 'List')
31 throw new Error(`Expected a List, got ${r.operator}: ${r.toString()}`);
32 return r.ops!.map((t) => {
33 if (t.operator !== 'Tuple')
34 throw new Error(`Expected a Tuple, got ${t.operator}: ${t.toString()}`);
35 return t.ops!.map((o) => o.re);
36 });
37}
38
39describe('SOLVE OVER A DOMAIN — symbolic + membership filter', () => {

Callers 1

Calls 3

evaluateMethod · 0.65
toStringMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected