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

Function countFunctionLeaves

src/math-json/utils.ts:465–471  ·  view source on GitHub ↗
(xs: MathJsonExpression[])

Source from the content-addressed store, hash-verified

463}
464
465function countFunctionLeaves(xs: MathJsonExpression[]): number {
466 if (xs[0] === 'Square') {
467 // Square is synonym with Power(..., 2)
468 return countFunctionLeaves(xs.slice(1)) + 2;
469 }
470 return xs.reduce<number>((acc, x) => acc + countLeaves(x), 0);
471}
472
473/** The number of leaves (atomic expressions) in the expression */
474export function countLeaves(expr: MathJsonExpression | null): number {

Callers 1

countLeavesFunction · 0.85

Calls 2

countLeavesFunction · 0.70
sliceMethod · 0.65

Tested by

no test coverage detected