mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
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:
+14
-13
@@ -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)'
|
||||
}());
|
||||
|
||||
Vendored
+5
-2
@@ -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;
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user