From 79c2ead09a395f5273d55e104e1293586a4b7914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20R=C3=B8nn-Jensen?= Date: Thu, 19 Nov 2015 10:58:57 +0100 Subject: [PATCH] Fixing last errors, but had to comment out an example from mathjs the example is mathjs.expression.node I couldnt find any explanation in examples --- mathjs/mathjs-tests.ts | 27 ++++++++++++++------------- mathjs/mathjs.d.ts | 7 +++++-- 2 files changed, 19 insertions(+), 15 deletions(-) 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; /** *