(xs: MathJsonExpression[])
| 463 | } |
| 464 | |
| 465 | function 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 */ |
| 474 | export function countLeaves(expr: MathJsonExpression | null): number { |
no test coverage detected