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

Function tuples

test/compute-engine/solve-diophantine.test.ts:12–21  ·  view source on GitHub ↗

Evaluate a multi-variable `Solve` and return its tuples as arrays of numbers * (each coordinate numericized). Throws if the result is not a `List` of * `Tuple`s. Order is preserved.

(expr: BoxedExpression)

Source from the content-addressed store, hash-verified

10 * (each coordinate numericized). Throws if the result is not a `List` of
11 * `Tuple`s. Order is preserved. */
12function tuples(expr: BoxedExpression): number[][] {
13 const r = expr.evaluate();
14 if (r.operator !== 'List')
15 throw new Error(`Expected a List, got ${r.operator}: ${r.toString()}`);
16 return r.ops!.map((t) => {
17 if (t.operator !== 'Tuple')
18 throw new Error(`Expected a Tuple, got ${t.operator}: ${t.toString()}`);
19 return t.ops!.map((o) => o.N().re);
20 });
21}
22
23/** True if the `Solve` expression stayed unevaluated (undecided / inert). */
24function isInert(expr: BoxedExpression): boolean {

Callers 1

Calls 4

evaluateMethod · 0.65
toStringMethod · 0.65
mapMethod · 0.65
NMethod · 0.65

Tested by

no test coverage detected