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

Function subs

src/math-json/utils.ts:373–388  ·  view source on GitHub ↗
(
  expr: MathJsonExpression,
  s: { [symbol: string]: MathJsonExpression }
)

Source from the content-addressed store, hash-verified

371}
372
373/**
374 * Apply a substitution to an expression.
375 */
376export function subs(
377 expr: MathJsonExpression,
378 s: { [symbol: string]: MathJsonExpression }
379): MathJsonExpression {
380 const sym = symbol(expr);
381 if (sym && s[sym]) return s[sym];
382
383 const h = operator(expr);
384 if (h)
385 return [
386 subs(h, s) as MathJsonSymbol,
387 ...operands(expr).map((x) => subs(x, s)),
388 ];
389
390 return expr;
391}

Callers

nothing calls this directly

Calls 4

operandsFunction · 0.85
symbolFunction · 0.70
operatorFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected