math-exercises 1.2.7 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/calcul/addAndSub.js +40 -0
- package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -0
- package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +31 -0
- package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -0
- package/lib/exercises/calcul/fractions/fractionsDivision.js +29 -0
- package/lib/exercises/calcul/fractions/fractionsProduct.js +29 -0
- package/lib/exercises/calcul/fractions/fractionsSum.js +29 -0
- package/lib/exercises/calcul/fractions/simplifyFraction.js +25 -0
- package/lib/exercises/calcul/operations/operationsPriorities.js +88 -0
- package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +111 -0
- package/{src → lib}/exercises/calcul/operationsPriorities.js +88 -89
- package/lib/exercises/calcul/rounding/rounding.js +86 -0
- package/{src → lib}/exercises/calculLitteral/distributivity/allIdentities.js +27 -27
- package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +31 -0
- package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +32 -0
- package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +33 -0
- package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +33 -0
- package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +32 -0
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +38 -0
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +41 -0
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +42 -0
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +44 -0
- package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +39 -0
- package/{src → lib}/exercises/exercise.js +7 -7
- package/lib/exercises/exercises.js +95 -0
- package/lib/exercises/geometry/cartesian/midpoint.js +29 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +29 -0
- package/lib/exercises/geometry/vectors/scalarProductViaNorms.js +27 -0
- package/lib/exercises/powers/powersDivision.js +45 -0
- package/lib/exercises/powers/powersOfTenToDecimal.js +33 -0
- package/lib/exercises/powers/powersPower.js +44 -0
- package/lib/exercises/powers/powersProduct.js +45 -0
- package/lib/exercises/powers/scientificToDecimal.js +38 -0
- package/{src → lib}/exercises/squareRoots/simpifySquareRoot.js +28 -28
- package/lib/exercises/utils/getDistinctQuestions.js +16 -0
- package/lib/geometry/point.js +27 -0
- package/lib/geometry/vector.js +31 -0
- package/lib/index.js +10 -0
- package/lib/mathutils/arithmetic/coprimesOf.js +13 -0
- package/lib/mathutils/arithmetic/dividersOf.js +12 -0
- package/{src → lib}/mathutils/arithmetic/gcd.js +7 -7
- package/{src → lib}/mathutils/arithmetic/isSquare.js +7 -7
- package/{src → lib}/mathutils/arithmetic/lcd.js +12 -12
- package/lib/mathutils/arithmetic/nonCoprimesOf.js +13 -0
- package/lib/mathutils/arithmetic/nonDividersOf.js +14 -0
- package/{src → lib}/mathutils/arithmetic/primeFactors.js +22 -22
- package/lib/mathutils/decimals/decimalPartLengthOf.js +14 -0
- package/lib/mathutils/random/randTupleInt.js +30 -0
- package/{src → lib}/mathutils/random/randint.js +18 -18
- package/{src → lib}/mathutils/round.js +8 -8
- package/{src → lib}/numbers/decimals/decimal.js +140 -144
- package/{src → lib}/numbers/epsilon.js +10 -10
- package/{src → lib}/numbers/integer/integer.js +68 -72
- package/{src → lib}/numbers/integer/power.js +52 -53
- package/{src → lib}/numbers/nombre.js +10 -10
- package/lib/numbers/rationals/rational.js +113 -0
- package/lib/numbers/reals/real.js +16 -0
- package/lib/numbers/reals/squareRoot.js +63 -0
- package/lib/polynomials/affine.js +42 -0
- package/lib/polynomials/polynomial.js +125 -0
- package/lib/sets/discreteSet.js +28 -0
- package/{src/sets/emptySet.ts → lib/sets/emptySet.js} +6 -6
- package/{src → lib}/sets/intervals/intervals.js +108 -113
- package/lib/sets/intervals/union.js +1 -0
- package/lib/sets/mathSet.js +10 -0
- package/lib/sets/mathSetInterface.js +2 -0
- package/{src → lib}/tree/nodes/functions/functionNode.js +18 -19
- package/lib/tree/nodes/functions/oppositeNode.js +13 -0
- package/lib/tree/nodes/functions/sqrtNode.js +15 -0
- package/{src → lib}/tree/nodes/node.js +10 -10
- package/lib/tree/nodes/numbers/numberNode.js +18 -0
- package/lib/tree/nodes/operators/addNode.js +15 -0
- package/lib/tree/nodes/operators/divideNode.js +17 -0
- package/lib/tree/nodes/operators/equalNode.js +13 -0
- package/lib/tree/nodes/operators/fractionNode.js +17 -0
- package/lib/tree/nodes/operators/multiplyNode.js +13 -0
- package/{src → lib}/tree/nodes/operators/operatorNode.js +35 -37
- package/lib/tree/nodes/operators/powerNode.js +13 -0
- package/lib/tree/nodes/operators/substractNode.js +13 -0
- package/lib/tree/nodes/variables/variableNode.js +16 -0
- package/{src → lib}/tree/parsers/derivateParser.js +60 -60
- package/{src → lib}/tree/parsers/latexParser.js +117 -117
- package/lib/utils/arrayEqual.js +13 -0
- package/{src → lib}/utils/coin.js +7 -7
- package/{src → lib}/utils/random.js +7 -7
- package/lib/utils/shuffle.js +15 -0
- package/package.json +35 -28
- package/nodemon.json +0 -5
- package/src/exercises/calcul/addAndSub.js +0 -40
- package/src/exercises/calcul/addAndSub.ts +0 -39
- package/src/exercises/calcul/fractions/fractionAndIntegerDivision.js +0 -35
- package/src/exercises/calcul/fractions/fractionAndIntegerDivision.ts +0 -38
- package/src/exercises/calcul/fractions/fractionAndIntegerProduct.js +0 -31
- package/src/exercises/calcul/fractions/fractionAndIntegerProduct.ts +0 -32
- package/src/exercises/calcul/fractions/fractionAndIntegerSum.js +0 -32
- package/src/exercises/calcul/fractions/fractionAndIntegerSum.ts +0 -31
- package/src/exercises/calcul/fractions/fractionsDivision.js +0 -29
- package/src/exercises/calcul/fractions/fractionsDivision.ts +0 -30
- package/src/exercises/calcul/fractions/fractionsProduct.js +0 -29
- package/src/exercises/calcul/fractions/fractionsProduct.ts +0 -29
- package/src/exercises/calcul/fractions/fractionsSum.js +0 -29
- package/src/exercises/calcul/fractions/fractionsSum.ts +0 -28
- package/src/exercises/calcul/fractions/simplifyFraction.js +0 -25
- package/src/exercises/calcul/fractions/simplifyFraction.ts +0 -24
- package/src/exercises/calcul/operationsPriorities.ts +0 -115
- package/src/exercises/calcul/rounding/roundToUnit.js +0 -70
- package/src/exercises/calcul/rounding/roundToUnit.ts +0 -68
- package/src/exercises/calculLitteral/distributivity/allIdentities.ts +0 -26
- package/src/exercises/calculLitteral/distributivity/doubleDistributivity.js +0 -31
- package/src/exercises/calculLitteral/distributivity/doubleDistributivity.ts +0 -33
- package/src/exercises/calculLitteral/distributivity/firstIdentity.js +0 -32
- package/src/exercises/calculLitteral/distributivity/firstIdentity.ts +0 -33
- package/src/exercises/calculLitteral/distributivity/secondIdentity.js +0 -33
- package/src/exercises/calculLitteral/distributivity/secondIdentity.ts +0 -35
- package/src/exercises/calculLitteral/distributivity/simpleDistributivity.js +0 -33
- package/src/exercises/calculLitteral/distributivity/simpleDistributivity.ts +0 -33
- package/src/exercises/calculLitteral/distributivity/thirdIdentity.js +0 -32
- package/src/exercises/calculLitteral/distributivity/thirdIdentity.ts +0 -34
- package/src/exercises/calculLitteral/equation/equationType1Exercise.js +0 -38
- package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +0 -38
- package/src/exercises/calculLitteral/equation/equationType2Exercise.js +0 -41
- package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +0 -41
- package/src/exercises/calculLitteral/equation/equationType3Exercise.js +0 -42
- package/src/exercises/calculLitteral/equation/equationType3Exercise.ts +0 -43
- package/src/exercises/calculLitteral/equation/equationType4Exercise.js +0 -44
- package/src/exercises/calculLitteral/equation/equationType4Exercise.ts +0 -46
- package/src/exercises/calculLitteral/factorisation/factoType1Exercise.js +0 -39
- package/src/exercises/calculLitteral/factorisation/factoType1Exercise.ts +0 -54
- package/src/exercises/calculLitteral/reduction.ts +0 -27
- package/src/exercises/exercise.ts +0 -25
- package/src/exercises/exercises.js +0 -86
- package/src/exercises/exercises.ts +0 -91
- package/src/exercises/powers/powersDivision.js +0 -46
- package/src/exercises/powers/powersDivision.ts +0 -51
- package/src/exercises/powers/powersOfTenToDecimal.js +0 -33
- package/src/exercises/powers/powersOfTenToDecimal.ts +0 -37
- package/src/exercises/powers/powersPower.js +0 -45
- package/src/exercises/powers/powersPower.ts +0 -55
- package/src/exercises/powers/powersProduct.js +0 -46
- package/src/exercises/powers/powersProduct.ts +0 -51
- package/src/exercises/powers/scientificToDecimal.js +0 -38
- package/src/exercises/powers/scientificToDecimal.ts +0 -44
- package/src/exercises/squareRoots/simpifySquareRoot.ts +0 -27
- package/src/exercises/utils/getDistinctQuestions.js +0 -18
- package/src/exercises/utils/getDistinctQuestions.ts +0 -14
- package/src/index.js +0 -10
- package/src/index.ts +0 -14
- package/src/mathutils/arithmetic/coprimesOf.js +0 -13
- package/src/mathutils/arithmetic/coprimesOf.ts +0 -9
- package/src/mathutils/arithmetic/dividersOf.ts +0 -7
- package/src/mathutils/arithmetic/gcd.ts +0 -3
- package/src/mathutils/arithmetic/isSquare.ts +0 -3
- package/src/mathutils/arithmetic/lcd.ts +0 -7
- package/src/mathutils/arithmetic/nonCoprimesOf.ts +0 -9
- package/src/mathutils/arithmetic/nonDividersOf.ts +0 -12
- package/src/mathutils/arithmetic/primeFactors.ts +0 -18
- package/src/mathutils/decimals/decimalPartLengthOf.ts +0 -10
- package/src/mathutils/random/randint.ts +0 -12
- package/src/mathutils/round.ts +0 -5
- package/src/numbers/decimals/decimal.ts +0 -140
- package/src/numbers/epsilon.ts +0 -7
- package/src/numbers/integer/integer.ts +0 -72
- package/src/numbers/integer/power.ts +0 -49
- package/src/numbers/nombre.ts +0 -15
- package/src/numbers/number.js +0 -8
- package/src/numbers/rationals/rational.js +0 -128
- package/src/numbers/rationals/rational.ts +0 -122
- package/src/numbers/reals/real.js +0 -17
- package/src/numbers/reals/real.ts +0 -17
- package/src/numbers/reals/squareRoot.js +0 -85
- package/src/numbers/reals/squareRoot.ts +0 -70
- package/src/polynomials/affine.js +0 -71
- package/src/polynomials/affine.ts +0 -60
- package/src/polynomials/polynomial.js +0 -128
- package/src/polynomials/polynomial.ts +0 -137
- package/src/sets/discreteSet.js +0 -30
- package/src/sets/discreteSet.ts +0 -30
- package/src/sets/intervals/intervals.ts +0 -122
- package/src/sets/intervals/union.ts +0 -0
- package/src/sets/mathSet.js +0 -11
- package/src/sets/mathSet.ts +0 -12
- package/src/sets/mathSetInterface.js +0 -2
- package/src/sets/mathSetInterface.ts +0 -10
- package/src/tree/latexParser/latexParse.js +0 -117
- package/src/tree/nodes/functions/functionNode.ts +0 -18
- package/src/tree/nodes/functions/oppositeNode.js +0 -30
- package/src/tree/nodes/functions/oppositeNode.ts +0 -12
- package/src/tree/nodes/functions/sqrtNode.js +0 -33
- package/src/tree/nodes/functions/sqrtNode.ts +0 -12
- package/src/tree/nodes/node.ts +0 -12
- package/src/tree/nodes/numbers/numberNode.js +0 -16
- package/src/tree/nodes/numbers/numberNode.ts +0 -16
- package/src/tree/nodes/operators/addNode.js +0 -33
- package/src/tree/nodes/operators/addNode.ts +0 -13
- package/src/tree/nodes/operators/divideNode.js +0 -34
- package/src/tree/nodes/operators/divideNode.ts +0 -16
- package/src/tree/nodes/operators/equalNode.js +0 -30
- package/src/tree/nodes/operators/equalNode.ts +0 -11
- package/src/tree/nodes/operators/fractionNode.js +0 -34
- package/src/tree/nodes/operators/fractionNode.ts +0 -16
- package/src/tree/nodes/operators/multiplyNode.js +0 -30
- package/src/tree/nodes/operators/multiplyNode.ts +0 -12
- package/src/tree/nodes/operators/operatorNode.ts +0 -36
- package/src/tree/nodes/operators/oppositeNode.js +0 -18
- package/src/tree/nodes/operators/powerNode.js +0 -30
- package/src/tree/nodes/operators/powerNode.ts +0 -12
- package/src/tree/nodes/operators/substractNode.js +0 -30
- package/src/tree/nodes/operators/substractNode.ts +0 -11
- package/src/tree/nodes/variables/variableNode.js +0 -17
- package/src/tree/nodes/variables/variableNode.ts +0 -15
- package/src/tree/parsers/derivateParser.ts +0 -66
- package/src/tree/parsers/latexParser.ts +0 -122
- package/src/utils/coin.ts +0 -3
- package/src/utils/random.ts +0 -3
- package/src/utils/randomIn.js +0 -7
- package/src/utils/shuffle.js +0 -24
- package/src/utils/shuffle.ts +0 -11
- package/tsconfig.json +0 -110
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
|
|
3
|
-
export enum FunctionsIds {
|
|
4
|
-
opposite,
|
|
5
|
-
sqrt,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export abstract class FunctionNode implements Node {
|
|
9
|
-
id: FunctionsIds;
|
|
10
|
-
child: Node;
|
|
11
|
-
type = NodeType.function;
|
|
12
|
-
tex: string;
|
|
13
|
-
constructor(id: FunctionsIds, child: Node, tex: string) {
|
|
14
|
-
this.id = id;
|
|
15
|
-
this.child = child;
|
|
16
|
-
this.tex = tex;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.OppositeNode = void 0;
|
|
19
|
-
var functionNode_1 = require("./functionNode");
|
|
20
|
-
var OppositeNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(OppositeNode, _super);
|
|
22
|
-
function OppositeNode(child) {
|
|
23
|
-
return _super.call(this, functionNode_1.FunctionsIds.opposite, child, "-") || this;
|
|
24
|
-
}
|
|
25
|
-
OppositeNode.prototype.toString = function () {
|
|
26
|
-
return "-(".concat(this.child, ")");
|
|
27
|
-
};
|
|
28
|
-
return OppositeNode;
|
|
29
|
-
}(functionNode_1.FunctionNode));
|
|
30
|
-
exports.OppositeNode = OppositeNode;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorNode } from "../operators/operatorNode";
|
|
3
|
-
import { FunctionNode, FunctionsIds } from "./functionNode";
|
|
4
|
-
|
|
5
|
-
export class OppositeNode extends FunctionNode {
|
|
6
|
-
constructor(child: Node) {
|
|
7
|
-
super(FunctionsIds.opposite, child, "-");
|
|
8
|
-
}
|
|
9
|
-
toString(): string {
|
|
10
|
-
return `-(${this.child})`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.SqrtNode = void 0;
|
|
19
|
-
var node_1 = require("../node");
|
|
20
|
-
var functionNode_1 = require("./functionNode");
|
|
21
|
-
var SqrtNode = /** @class */ (function (_super) {
|
|
22
|
-
__extends(SqrtNode, _super);
|
|
23
|
-
function SqrtNode(child) {
|
|
24
|
-
var _this = _super.call(this, functionNode_1.FunctionsIds.sqrt, child, "\\sqrt") || this;
|
|
25
|
-
_this.type = node_1.NodeType["function"];
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
SqrtNode.prototype.toString = function () {
|
|
29
|
-
return "sqrt(".concat(this.child, ")");
|
|
30
|
-
};
|
|
31
|
-
return SqrtNode;
|
|
32
|
-
}(functionNode_1.FunctionNode));
|
|
33
|
-
exports.SqrtNode = SqrtNode;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { FunctionNode, FunctionsIds } from "./functionNode";
|
|
3
|
-
|
|
4
|
-
export class SqrtNode extends FunctionNode {
|
|
5
|
-
type: NodeType = NodeType.function;
|
|
6
|
-
constructor(child: Node) {
|
|
7
|
-
super(FunctionsIds.sqrt, child, "\\sqrt");
|
|
8
|
-
}
|
|
9
|
-
toString(): string {
|
|
10
|
-
return `sqrt(${this.child})`;
|
|
11
|
-
}
|
|
12
|
-
}
|
package/src/tree/nodes/node.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.NumberNode = void 0;
|
|
4
|
-
var node_1 = require("../node");
|
|
5
|
-
var NumberNode = /** @class */ (function () {
|
|
6
|
-
function NumberNode(value, tex) {
|
|
7
|
-
this.type = node_1.NodeType.number;
|
|
8
|
-
this.value = value;
|
|
9
|
-
this.tex = tex || value + "";
|
|
10
|
-
}
|
|
11
|
-
NumberNode.prototype.toString = function () {
|
|
12
|
-
return "".concat(this.tex);
|
|
13
|
-
};
|
|
14
|
-
return NumberNode;
|
|
15
|
-
}());
|
|
16
|
-
exports.NumberNode = NumberNode;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
|
|
3
|
-
export class NumberNode implements Node {
|
|
4
|
-
tex: string;
|
|
5
|
-
value: number;
|
|
6
|
-
type: NodeType = NodeType.number;
|
|
7
|
-
|
|
8
|
-
constructor(value: number, tex?: string) {
|
|
9
|
-
this.value = value;
|
|
10
|
-
this.tex = tex || value + "";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
toString(): string {
|
|
14
|
-
return `${this.tex}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.AddNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var AddNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(AddNode, _super);
|
|
22
|
-
function AddNode(leftChild, rightChild) {
|
|
23
|
-
var _this = _super.call(this, operatorNode_1.OperatorIds.add, leftChild, rightChild, true, "+") || this;
|
|
24
|
-
_this.leftChild = leftChild;
|
|
25
|
-
_this.rightChild = rightChild;
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
AddNode.prototype.toString = function () {
|
|
29
|
-
return "".concat(this.leftChild, " + ").concat(this.rightChild);
|
|
30
|
-
};
|
|
31
|
-
return AddNode;
|
|
32
|
-
}(operatorNode_1.OperatorNode));
|
|
33
|
-
exports.AddNode = AddNode;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class AddNode extends OperatorNode {
|
|
5
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
6
|
-
super(OperatorIds.add, leftChild, rightChild, true, "+");
|
|
7
|
-
this.leftChild = leftChild;
|
|
8
|
-
this.rightChild = rightChild;
|
|
9
|
-
}
|
|
10
|
-
toString(): string {
|
|
11
|
-
return `${this.leftChild} + ${this.rightChild}`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.DivideNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var DivideNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(DivideNode, _super);
|
|
22
|
-
/**
|
|
23
|
-
* @param leftChild num
|
|
24
|
-
* @param rightChild denum
|
|
25
|
-
*/
|
|
26
|
-
function DivideNode(leftChild, rightChild) {
|
|
27
|
-
return _super.call(this, operatorNode_1.OperatorIds.divide, leftChild, rightChild, false, "\\div") || this;
|
|
28
|
-
}
|
|
29
|
-
DivideNode.prototype.toString = function () {
|
|
30
|
-
return "(".concat(this.leftChild, ") \\div (").concat(this.rightChild, ")");
|
|
31
|
-
};
|
|
32
|
-
return DivideNode;
|
|
33
|
-
}(operatorNode_1.OperatorNode));
|
|
34
|
-
exports.DivideNode = DivideNode;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class DivideNode extends OperatorNode {
|
|
5
|
-
/**
|
|
6
|
-
* @param leftChild num
|
|
7
|
-
* @param rightChild denum
|
|
8
|
-
*/
|
|
9
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
10
|
-
super(OperatorIds.divide, leftChild, rightChild, false, "\\div");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
toString(): string {
|
|
14
|
-
return `(${this.leftChild}) \\div (${this.rightChild})`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.EqualNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var EqualNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(EqualNode, _super);
|
|
22
|
-
function EqualNode(leftChild, rightChild) {
|
|
23
|
-
return _super.call(this, operatorNode_1.OperatorIds.equal, leftChild, rightChild, true, "=") || this;
|
|
24
|
-
}
|
|
25
|
-
EqualNode.prototype.toString = function () {
|
|
26
|
-
return "".concat(this.leftChild, " = ").concat(this.rightChild);
|
|
27
|
-
};
|
|
28
|
-
return EqualNode;
|
|
29
|
-
}(operatorNode_1.OperatorNode));
|
|
30
|
-
exports.EqualNode = EqualNode;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class EqualNode extends OperatorNode {
|
|
5
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
6
|
-
super(OperatorIds.equal, leftChild, rightChild, true, "=");
|
|
7
|
-
}
|
|
8
|
-
toString(): string {
|
|
9
|
-
return `${this.leftChild} = ${this.rightChild}`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.FractionNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var FractionNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(FractionNode, _super);
|
|
22
|
-
/**
|
|
23
|
-
* @param leftChild num
|
|
24
|
-
* @param rightChild denum
|
|
25
|
-
*/
|
|
26
|
-
function FractionNode(leftChild, rightChild) {
|
|
27
|
-
return _super.call(this, operatorNode_1.OperatorIds.fraction, leftChild, rightChild, false, "\\frac") || this;
|
|
28
|
-
}
|
|
29
|
-
FractionNode.prototype.toString = function () {
|
|
30
|
-
return "\\frac{".concat(this.leftChild, "}{").concat(this.rightChild, "}");
|
|
31
|
-
};
|
|
32
|
-
return FractionNode;
|
|
33
|
-
}(operatorNode_1.OperatorNode));
|
|
34
|
-
exports.FractionNode = FractionNode;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class FractionNode extends OperatorNode {
|
|
5
|
-
/**
|
|
6
|
-
* @param leftChild num
|
|
7
|
-
* @param rightChild denum
|
|
8
|
-
*/
|
|
9
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
10
|
-
super(OperatorIds.fraction, leftChild, rightChild, false, "\\frac");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
toString(): string {
|
|
14
|
-
return `\\frac{${this.leftChild}}{${this.rightChild}}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.MultiplyNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var MultiplyNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(MultiplyNode, _super);
|
|
22
|
-
function MultiplyNode(leftChild, rightChild) {
|
|
23
|
-
return _super.call(this, operatorNode_1.OperatorIds.multiply, leftChild, rightChild, true, "\\times") || this;
|
|
24
|
-
}
|
|
25
|
-
MultiplyNode.prototype.toString = function () {
|
|
26
|
-
return "(".concat(this.leftChild, ")*(").concat(this.rightChild, ")");
|
|
27
|
-
};
|
|
28
|
-
return MultiplyNode;
|
|
29
|
-
}(operatorNode_1.OperatorNode));
|
|
30
|
-
exports.MultiplyNode = MultiplyNode;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class MultiplyNode extends OperatorNode {
|
|
5
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
6
|
-
super(OperatorIds.multiply, leftChild, rightChild, true, "\\times");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
toString(): string {
|
|
10
|
-
return `(${this.leftChild})*(${this.rightChild})`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { coin } from "../../../utils/coin";
|
|
2
|
-
import { Node, NodeType } from "../node";
|
|
3
|
-
|
|
4
|
-
export enum OperatorIds {
|
|
5
|
-
add,
|
|
6
|
-
substract,
|
|
7
|
-
multiply,
|
|
8
|
-
fraction,
|
|
9
|
-
divide,
|
|
10
|
-
power,
|
|
11
|
-
equal,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export abstract class OperatorNode implements Node {
|
|
15
|
-
id: OperatorIds;
|
|
16
|
-
leftChild: Node;
|
|
17
|
-
rightChild: Node;
|
|
18
|
-
isCommutative: boolean;
|
|
19
|
-
type = NodeType.operator;
|
|
20
|
-
tex: string;
|
|
21
|
-
constructor(id: OperatorIds, leftChild: Node, rightChild: Node, isCommutative: boolean, tex: string) {
|
|
22
|
-
this.id = id;
|
|
23
|
-
this.leftChild = leftChild;
|
|
24
|
-
this.rightChild = rightChild;
|
|
25
|
-
this.isCommutative = isCommutative;
|
|
26
|
-
this.tex = tex;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**shuffles in place */
|
|
30
|
-
shuffle(): Node {
|
|
31
|
-
if (!this.isCommutative) return this;
|
|
32
|
-
if (coin()) return this;
|
|
33
|
-
[this.leftChild, this.rightChild] = [this.rightChild, this.leftChild];
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.OppositeNode = void 0;
|
|
4
|
-
var node_1 = require("../node");
|
|
5
|
-
var OppositeNode = /** @class */ (function () {
|
|
6
|
-
function OppositeNode(leftChild) {
|
|
7
|
-
this.type = node_1.NodeType.operator;
|
|
8
|
-
this.id = "opposite";
|
|
9
|
-
this.tex = "-";
|
|
10
|
-
this.leftChild = leftChild;
|
|
11
|
-
this.rightChild = null;
|
|
12
|
-
}
|
|
13
|
-
OppositeNode.prototype.toString = function () {
|
|
14
|
-
return "-(".concat(this.leftChild, ")");
|
|
15
|
-
};
|
|
16
|
-
return OppositeNode;
|
|
17
|
-
}());
|
|
18
|
-
exports.OppositeNode = OppositeNode;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.PowerNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var PowerNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(PowerNode, _super);
|
|
22
|
-
function PowerNode(leftChild, rightChild) {
|
|
23
|
-
return _super.call(this, operatorNode_1.OperatorIds.power, leftChild, rightChild, false, "^") || this;
|
|
24
|
-
}
|
|
25
|
-
PowerNode.prototype.toString = function () {
|
|
26
|
-
return "(".concat(this.leftChild, ")^{").concat(this.rightChild, "}");
|
|
27
|
-
};
|
|
28
|
-
return PowerNode;
|
|
29
|
-
}(operatorNode_1.OperatorNode));
|
|
30
|
-
exports.PowerNode = PowerNode;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class PowerNode extends OperatorNode {
|
|
5
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
6
|
-
super(OperatorIds.power, leftChild, rightChild, false, "^");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
toString(): string {
|
|
10
|
-
return `(${this.leftChild})^{${this.rightChild}}`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.SubstractNode = void 0;
|
|
19
|
-
var operatorNode_1 = require("./operatorNode");
|
|
20
|
-
var SubstractNode = /** @class */ (function (_super) {
|
|
21
|
-
__extends(SubstractNode, _super);
|
|
22
|
-
function SubstractNode(leftChild, rightChild) {
|
|
23
|
-
return _super.call(this, operatorNode_1.OperatorIds.substract, leftChild, rightChild, false, "-") || this;
|
|
24
|
-
}
|
|
25
|
-
SubstractNode.prototype.toString = function () {
|
|
26
|
-
return "".concat(this.leftChild, "-(").concat(this.rightChild, ")");
|
|
27
|
-
};
|
|
28
|
-
return SubstractNode;
|
|
29
|
-
}(operatorNode_1.OperatorNode));
|
|
30
|
-
exports.SubstractNode = SubstractNode;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class SubstractNode extends OperatorNode {
|
|
5
|
-
constructor(leftChild: Node, rightChild: Node) {
|
|
6
|
-
super(OperatorIds.substract, leftChild, rightChild, false, "-");
|
|
7
|
-
}
|
|
8
|
-
toString(): string {
|
|
9
|
-
return `${this.leftChild}-(${this.rightChild})`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.VariableNode = void 0;
|
|
4
|
-
var node_1 = require("../node");
|
|
5
|
-
var VariableNode = /** @class */ (function () {
|
|
6
|
-
function VariableNode(tex) {
|
|
7
|
-
this.type = node_1.NodeType.variable;
|
|
8
|
-
if (tex.length !== 1 || !tex.match("[a-zA-Z]"))
|
|
9
|
-
throw Error("variable must be a letter");
|
|
10
|
-
this.tex = tex;
|
|
11
|
-
}
|
|
12
|
-
VariableNode.prototype.toString = function () {
|
|
13
|
-
return "".concat(this.tex);
|
|
14
|
-
};
|
|
15
|
-
return VariableNode;
|
|
16
|
-
}());
|
|
17
|
-
exports.VariableNode = VariableNode;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
|
|
3
|
-
export class VariableNode implements Node {
|
|
4
|
-
tex: string;
|
|
5
|
-
type = NodeType.variable;
|
|
6
|
-
|
|
7
|
-
constructor(tex: string) {
|
|
8
|
-
if (tex.length !== 1 || !tex.match("[a-zA-Z]")) throw Error("variable must be a letter");
|
|
9
|
-
this.tex = tex;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
toString(): string {
|
|
13
|
-
return `${this.tex}`;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../nodes/node";
|
|
2
|
-
import { NumberNode } from "../nodes/numbers/numberNode";
|
|
3
|
-
import { PowerNode } from "../nodes/operators/powerNode";
|
|
4
|
-
|
|
5
|
-
import { AddNode } from "../nodes/operators/addNode";
|
|
6
|
-
import { FractionNode } from "../nodes/operators/fractionNode";
|
|
7
|
-
import { MultiplyNode } from "../nodes/operators/multiplyNode";
|
|
8
|
-
import { OperatorIds, OperatorNode } from "../nodes/operators/operatorNode";
|
|
9
|
-
import { SubstractNode } from "../nodes/operators/substractNode";
|
|
10
|
-
import { FunctionNode, FunctionsIds } from "../nodes/functions/functionNode";
|
|
11
|
-
import { SqrtNode } from "../nodes/functions/sqrtNode";
|
|
12
|
-
import { OppositeNode } from "../nodes/functions/oppositeNode";
|
|
13
|
-
|
|
14
|
-
export function derivateParser(node: Node): Node {
|
|
15
|
-
if (!node) throw Error("encountered a null node ??");
|
|
16
|
-
|
|
17
|
-
switch (node.type) {
|
|
18
|
-
case NodeType.variable:
|
|
19
|
-
return new NumberNode(1);
|
|
20
|
-
case NodeType.number:
|
|
21
|
-
return new NumberNode(0);
|
|
22
|
-
case NodeType.operator:
|
|
23
|
-
const operatorNode = node as OperatorNode;
|
|
24
|
-
const u = operatorNode.leftChild;
|
|
25
|
-
const v = operatorNode.rightChild;
|
|
26
|
-
switch (operatorNode.id) {
|
|
27
|
-
case OperatorIds.add:
|
|
28
|
-
return new AddNode(derivateParser(u), derivateParser(v));
|
|
29
|
-
case OperatorIds.substract: {
|
|
30
|
-
return new SubstractNode(derivateParser(u), derivateParser(v));
|
|
31
|
-
}
|
|
32
|
-
case OperatorIds.multiply: {
|
|
33
|
-
return new AddNode(new MultiplyNode(derivateParser(u), v), new MultiplyNode(u, derivateParser(v)));
|
|
34
|
-
}
|
|
35
|
-
case OperatorIds.divide:
|
|
36
|
-
case OperatorIds.fraction:
|
|
37
|
-
return new FractionNode(
|
|
38
|
-
new SubstractNode(new MultiplyNode(derivateParser(u), v), new MultiplyNode(u, derivateParser(v))),
|
|
39
|
-
new PowerNode(v, new NumberNode(2))
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
case OperatorIds.power: {
|
|
43
|
-
const operatorNode = node as OperatorNode;
|
|
44
|
-
const n = operatorNode.rightChild as NumberNode;
|
|
45
|
-
const u = operatorNode.leftChild;
|
|
46
|
-
return new MultiplyNode(
|
|
47
|
-
n,
|
|
48
|
-
new MultiplyNode(derivateParser(u), new PowerNode(u, new NumberNode(n.value - 1)))
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
case NodeType.function: {
|
|
53
|
-
const functionNode = node as FunctionNode;
|
|
54
|
-
const child = functionNode.child;
|
|
55
|
-
switch (functionNode.id) {
|
|
56
|
-
case FunctionsIds.sqrt: {
|
|
57
|
-
return new FractionNode(derivateParser(child), new MultiplyNode(new NumberNode(2), new SqrtNode(child)));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
case FunctionsIds.opposite: {
|
|
61
|
-
return new OppositeNode(derivateParser(child));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|