Math parser, AST builder for math expression & step by step solution
This library is part of an educational project. Its main goal is to give a step by step solution for any mathematical expression.
npm install --save @math-x-ts/parser
or
yarn add @math-x-ts/parser
import { evaluate } from '@math-x-ts/parser';
console.log(evaluate('4 * (1 + 2)')) // 12;
import { parse } from '@math-x-ts/parser';
const mathNode = parse('4 * (1 + 2)');
const steps = mathNode.solveAll();
console.log(steps[0].toString()); // '4 * (1 + 2)'
console.log(steps[1].toString()); // '4 * 3'
console.log(steps[2].toString()); // '12'
Thanks goes to these wonderful people (emoji key):
Dopey2 💻 🤔 |
This project follows the all-contributors specification. Contributions of any kind welcome!