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

Function serializeFunction

src/math-json/serialize-sympy.ts:53–69  ·  view source on GitHub ↗
(expr: Expression)

Source from the content-addressed store, hash-verified

51}
52
53function serializeFunction(expr: Expression): string | null {
54 const result = serializeBaseForm(expr);
55 if (result !== null) return result;
56
57 const h = operator(expr);
58 if (!h) return null;
59
60 // Special SymPy spellings are not implemented for these heads:
61 // Add, Multiply, Root, Power, Exp, Subtract, Divide, Negate,
62 // List, Tuple, Pair, KeyValuePair,
63 // String, Number,
64
65 const args = operands(expr);
66 if (args.length === 0) return null;
67 return `${h}(${args.map((x) => serializeExpression(x) ?? '')})`;
68 // Lambda serialization is not supported.
69}
70
71function serializeExpression(expr: Expression): string {
72 return (

Callers 1

serializeExpressionFunction · 0.70

Calls 5

operatorFunction · 0.90
operandsFunction · 0.90
serializeBaseFormFunction · 0.85
serializeExpressionFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected