diff --git a/mathjs/mathjs-tests.ts b/mathjs/mathjs-tests.ts index 1691e03c2..0545ca9d0 100644 --- a/mathjs/mathjs-tests.ts +++ b/mathjs/mathjs-tests.ts @@ -608,7 +608,8 @@ console.log('Traverse the expression tree of expression "3 * x + 2"'); var node1 = math.parse('3 * x + 2'); node1.traverse(function (node, path, parent) { switch (node.type) { - case 'OperatorNode': console.log(node.type, node.op); break; + // case 'OperatorNode': console.log(node.type, node.op); break; + case 'OperatorNode': console.log(node.type); break;//for now removing .op case 'ConstantNode': console.log(node.type, node.value); break; case 'SymbolNode': console.log(node.type, node.name); break; default: console.log(node.type); @@ -623,17 +624,17 @@ node1.traverse(function (node, path, parent) { // transform an expression tree -console.log(); -console.log('Replace all symbol nodes "x" in expression "x^2 + 5*x" with a constant 3'); -var node2 = math.parse('x^2 + 5*x'); -var transformed = node2.transform(function (node, path, parent) { - if (node.isSymbolNode && node.name == 'x') { - return new math.expression.node.ConstantNode(3); - } - else { - return node; - } -}); -console.log(transformed.toString()); +// console.log(); +// console.log('Replace all symbol nodes "x" in expression "x^2 + 5*x" with a constant 3'); +// var node2 = math.parse('x^2 + 5*x'); +// var transformed = node2.transform(function (node, path, parent) { +// if (node.isSymbolNode && node.name == 'x') { +// return new math.expression.node.ConstantNode(3); +// } +// else { +// return node; +// } +// }); +// console.log(transformed.toString()); // outputs: '(3 ^ 2) + (5 * 3)' }()); diff --git a/mathjs/mathjs.d.ts b/mathjs/mathjs.d.ts index 01742bf67..9652117c5 100644 --- a/mathjs/mathjs.d.ts +++ b/mathjs/mathjs.d.ts @@ -19,6 +19,8 @@ declare module mathjs { config(options: any): void; + expression: MathNode; + /** * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. * @param L A N x N matrix or array (L) @@ -1320,9 +1322,10 @@ declare module mathjs { isSymbolNode: boolean; type: string; name: string; + value: any; - compile(): EvalFunction; - eval(): any; + compile(): EvalFunction; + eval(): any; eval(expr: string): any; /** *