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
This commit is contained in:
Jesper Rønn-Jensen
2015-12-04 12:39:10 +01:00
parent f4b4073a44
commit 79c2ead09a
2 changed files with 19 additions and 15 deletions
+14 -13
View File
@@ -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)'
}());
+5 -2
View File
@@ -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;
/**
*