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

Function customCanonical

test/compute-engine/smoke.test.ts:39–54  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

37}
38
39function customCanonical(expr) {
40 if (typeof expr.value === 'number') {
41 if (expr.head === 'Divide' || expr.head === 'Rational') {
42 if (expr.engine.expr(['GCD', expr.op1, expr.op2]).value !== 1)
43 return expr;
44 }
45 return expr.engine.number(expr.value);
46 }
47
48 if (expr.ops)
49 return expr.engine.expr([expr.head, ...expr.ops.map(customCanonical)], {
50 form: ['InvisibleOperator', 'Order', 'Flatten'],
51 });
52
53 return expr.canonical;
54}
55
56//
57// PARSING

Callers

nothing calls this directly

Calls 3

exprMethod · 0.65
numberMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected