math-exercises 2.0.19 → 2.0.21
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/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.js +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.js +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.js +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.js +1 -1
- package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts +12 -0
- package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/alignementViaColinearity.js +61 -0
- package/lib/exercises/geometry/vectors/colinearity.d.ts +10 -0
- package/lib/exercises/geometry/vectors/colinearity.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/colinearity.js +59 -0
- package/lib/exercises/geometry/vectors/index.d.ts +1 -0
- package/lib/exercises/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/geometry/vectors/index.js +2 -0
- package/lib/exercises/probaStat/independancy.d.ts +9 -0
- package/lib/exercises/probaStat/independancy.d.ts.map +1 -0
- package/lib/exercises/probaStat/independancy.js +59 -0
- package/lib/exercises/probaStat/index.d.ts +1 -0
- package/lib/exercises/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/probaStat/index.js +1 -0
- package/lib/exercises/trigonometry/remarkableValues.js +1 -1
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts +10 -0
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +34 -0
- package/lib/math/geometry/point.d.ts +4 -15
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +28 -20
- package/lib/math/geometry/vector.d.ts +8 -5
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +13 -3
- package/lib/math/numbers/decimals/decimal.d.ts +1 -2
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +31 -87
- package/lib/server.js +29 -7
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +2 -1
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +6 -3
- package/lib/tree/nodes/operators/substractNode.js +1 -1
- package/lib/tree/parsers/latexParser.d.ts +1 -0
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +240 -133
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAY1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAK/D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;CAMrD;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,aAAsB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,MAAM;IASzB;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIhC,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAkClC,gBAAgB;IA2BhB,oBAAoB;IAsBpB,UAAU;IAMV,MAAM;CAGP"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Decimal = exports.DecimalConstructor = void 0;
|
|
4
4
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
5
|
+
const round_1 = require("../../../math/utils/round");
|
|
5
6
|
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
6
7
|
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
7
8
|
const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
|
|
8
|
-
const integer_1 = require("../integer/integer");
|
|
9
9
|
const nombre_1 = require("../nombre");
|
|
10
10
|
const rational_1 = require("../rationals/rational");
|
|
11
11
|
class DecimalConstructor {
|
|
@@ -21,6 +21,7 @@ class DecimalConstructor {
|
|
|
21
21
|
}
|
|
22
22
|
return decimals;
|
|
23
23
|
}
|
|
24
|
+
//! a refacto, pour inclure "-0" et des min/max décimaux
|
|
24
25
|
static random(min, max, precision) {
|
|
25
26
|
let prec = precision ?? (0, randint_1.randint)(1, 4);
|
|
26
27
|
const int = (0, randint_1.randint)(min, max) + "";
|
|
@@ -57,84 +58,14 @@ class Decimal {
|
|
|
57
58
|
* @returns
|
|
58
59
|
*/
|
|
59
60
|
round(precision) {
|
|
60
|
-
|
|
61
|
-
if (precision < 0) {
|
|
62
|
-
if (precision < -intPartString.length)
|
|
63
|
-
throw Error("can't round to higher precision");
|
|
64
|
-
return new integer_1.Integer(this.intPart).round(-precision);
|
|
65
|
-
}
|
|
66
|
-
if (precision > this.precision)
|
|
67
|
-
throw Error("can't round to higher precision");
|
|
68
|
-
if (precision === this.precision)
|
|
69
|
-
return this;
|
|
70
|
-
let newFracPart = "", newIntPart = "";
|
|
71
|
-
const shouldRoundUp = Number(this.decimalPart[precision]) > 4;
|
|
72
|
-
if (shouldRoundUp) {
|
|
73
|
-
let retenue = true;
|
|
74
|
-
let i = precision - 1;
|
|
75
|
-
while (retenue) {
|
|
76
|
-
if (i > -1) {
|
|
77
|
-
const nb = (Number(this.decimalPart[i]) + 1) % 10;
|
|
78
|
-
if (nb || newFracPart) {
|
|
79
|
-
newFracPart = nb.toString() + newFracPart;
|
|
80
|
-
}
|
|
81
|
-
if (nb !== 0) {
|
|
82
|
-
retenue = false;
|
|
83
|
-
for (let j = i - 1; j > -1; j--) {
|
|
84
|
-
newFracPart = this.decimalPart[j] + newFracPart;
|
|
85
|
-
}
|
|
86
|
-
newIntPart = intPartString;
|
|
87
|
-
}
|
|
88
|
-
else
|
|
89
|
-
i--;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
const nb = (Number(intPartString[i + intPartString.length]) + 1) % 10;
|
|
93
|
-
newIntPart = nb + "" + newIntPart;
|
|
94
|
-
if (nb !== 0) {
|
|
95
|
-
retenue = false;
|
|
96
|
-
for (let j = i + intPartString.length - 1; j > -1; j--) {
|
|
97
|
-
newIntPart = intPartString[j] + newIntPart;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else
|
|
101
|
-
i--;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
let retenue = true;
|
|
107
|
-
let i = precision - 1;
|
|
108
|
-
while (retenue) {
|
|
109
|
-
if (i > -1) {
|
|
110
|
-
const nb = Number(this.decimalPart[i]);
|
|
111
|
-
if (nb || newFracPart) {
|
|
112
|
-
newFracPart = nb.toString() + newFracPart;
|
|
113
|
-
}
|
|
114
|
-
if (nb !== 0) {
|
|
115
|
-
retenue = false;
|
|
116
|
-
for (let j = i - 1; j > -1; j--) {
|
|
117
|
-
newFracPart = this.decimalPart[j] + newFracPart;
|
|
118
|
-
}
|
|
119
|
-
newIntPart = intPartString;
|
|
120
|
-
}
|
|
121
|
-
else
|
|
122
|
-
i--;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
newIntPart = intPartString;
|
|
126
|
-
retenue = false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
61
|
+
return new Decimal((0, round_1.round)(this.value, precision));
|
|
131
62
|
}
|
|
132
63
|
multiplyByPowerOfTen(power) {
|
|
133
64
|
if (power === 0)
|
|
134
65
|
return this;
|
|
135
66
|
let newIntPart = "", newFracPart = "";
|
|
136
|
-
if (power >
|
|
137
|
-
newIntPart = this.
|
|
67
|
+
if (power > 0) {
|
|
68
|
+
newIntPart = (this.value + "").split(".")[0];
|
|
138
69
|
for (let i = 0; i < power; i++) {
|
|
139
70
|
newIntPart +=
|
|
140
71
|
i > this.decimalPart.length - 1 ? "0" : this.decimalPart[i];
|
|
@@ -142,35 +73,46 @@ class Decimal {
|
|
|
142
73
|
newFracPart = this.decimalPart.slice(power);
|
|
143
74
|
}
|
|
144
75
|
else {
|
|
145
|
-
const intPartString = this.intPart
|
|
76
|
+
const intPartString = this.intPart.toString().replace("-", "");
|
|
77
|
+
const isNegative = this.value < 0;
|
|
146
78
|
newFracPart = this.decimalPart;
|
|
147
79
|
for (let i = intPartString.length - 1; i > intPartString.length - 1 + power; i--) {
|
|
148
80
|
newFracPart = (i < 0 ? "0" : intPartString[i]) + newFracPart;
|
|
149
81
|
}
|
|
150
82
|
if (power + intPartString.length < 1)
|
|
151
|
-
newIntPart = "0";
|
|
83
|
+
newIntPart = isNegative ? "-0" : "0";
|
|
152
84
|
else
|
|
153
|
-
newIntPart =
|
|
85
|
+
newIntPart =
|
|
86
|
+
(isNegative ? "-" : "") +
|
|
87
|
+
intPartString.slice(0, power + intPartString.length);
|
|
154
88
|
}
|
|
89
|
+
console.log("in", newIntPart, newFracPart);
|
|
155
90
|
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
156
91
|
}
|
|
157
92
|
toScientificPart() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
93
|
+
if (!this.decimalPart.length)
|
|
94
|
+
return new numberNode_1.NumberNode(this.intPart);
|
|
95
|
+
// const intString = this.intPart.toString();
|
|
96
|
+
// const intSize = intString.length;
|
|
97
|
+
// if (intSize === 0 && this.intPart !== 0) return this.toTree();
|
|
162
98
|
if (this.intPart === 0) {
|
|
99
|
+
//true for -0
|
|
163
100
|
const firstNonZeroIndex = this.decimalPart
|
|
164
101
|
.split("")
|
|
165
102
|
.findIndex((el) => Number(el) !== 0);
|
|
166
|
-
return new numberNode_1.NumberNode(Number("0."
|
|
103
|
+
return new numberNode_1.NumberNode(Number((this.tex[0] === "-" ? "-0." : "0.") +
|
|
104
|
+
this.decimalPart.slice(firstNonZeroIndex)));
|
|
167
105
|
}
|
|
168
|
-
|
|
106
|
+
const intString = this.intPart + "";
|
|
107
|
+
return new numberNode_1.NumberNode(Number((this.tex[0] === "-" ? "-" + this.tex[1] : this.tex[0]) +
|
|
108
|
+
"." +
|
|
109
|
+
(this.tex[0] === "-" ? intString.slice(2) : intString.slice(1)) +
|
|
110
|
+
this.decimalPart));
|
|
169
111
|
}
|
|
170
112
|
toScientificNotation() {
|
|
171
|
-
const intString = this.intPart
|
|
172
|
-
const intSize = intString.length;
|
|
173
|
-
if (
|
|
113
|
+
const intString = this.intPart + "";
|
|
114
|
+
// const intSize = intString.length + (this.value < 0 ? 1 : 0);
|
|
115
|
+
if (this.intPart > -10 && this.intPart < 10 && this.intPart !== 0)
|
|
174
116
|
return this.toTree();
|
|
175
117
|
const decNode = this.toScientificPart();
|
|
176
118
|
let leadingZeros = 0;
|
|
@@ -180,7 +122,9 @@ class Decimal {
|
|
|
180
122
|
break;
|
|
181
123
|
leadingZeros++;
|
|
182
124
|
}
|
|
183
|
-
const power = this.intPart === 0 ? -leadingZeros :
|
|
125
|
+
const power = this.intPart === 0 ? -leadingZeros : (this.intPart + "").length - 1;
|
|
126
|
+
if (power === 0)
|
|
127
|
+
return this.toTree();
|
|
184
128
|
if (power === 1)
|
|
185
129
|
return new multiplyNode_1.MultiplyNode(decNode, new numberNode_1.NumberNode(10));
|
|
186
130
|
return new multiplyNode_1.MultiplyNode(decNode, new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(power)));
|
package/lib/server.js
CHANGED
|
@@ -35,19 +35,41 @@ const express_1 = __importDefault(require("express"));
|
|
|
35
35
|
const body_parser_1 = __importDefault(require("body-parser"));
|
|
36
36
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
37
37
|
const cors_1 = __importDefault(require("cors"));
|
|
38
|
+
const decimal_1 = require("./math/numbers/decimals/decimal");
|
|
38
39
|
const jsonParser = body_parser_1.default.json();
|
|
39
40
|
const allExercises = [...exercises];
|
|
40
41
|
const runServer = () => {
|
|
41
42
|
dotenv_1.default.config();
|
|
42
43
|
const app = (0, express_1.default)();
|
|
43
44
|
app.use((0, cors_1.default)());
|
|
44
|
-
// const
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
45
|
+
// const string = "\\frac{9}{12}";
|
|
46
|
+
// const a = string.match(/^[0-9]+,?[0-9]*/);
|
|
47
|
+
// const before = Date.now();
|
|
48
|
+
// const parsed = parseLatex(string);
|
|
49
|
+
// console.log("res", parsed);
|
|
50
|
+
// console.log(parsed?.toTex());
|
|
51
|
+
// console.log(parsed?.simplify().toTex());
|
|
52
|
+
// console.log(parsed?.evaluate({ x: 1 }));
|
|
53
|
+
// console.log("time", Date.now() - before);
|
|
54
|
+
// tokenize(string);
|
|
55
|
+
// const a = DecimalConstructor.random(-4, 8);
|
|
56
|
+
// const a = new Decimal(-0.0009343);
|
|
57
|
+
// console.log(a.value, a.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
58
|
+
// const b = new Decimal(0.0009343);
|
|
59
|
+
// console.log(b.value, b.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
60
|
+
// const c = new Decimal(-2.00009343);
|
|
61
|
+
// console.log(c.value, c.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
62
|
+
// const d = new Decimal(2.009343);
|
|
63
|
+
// console.log(d.value, d.multiplyByPowerOfTen(-2).toTree().toTex());
|
|
64
|
+
const power = 1;
|
|
65
|
+
const a = new decimal_1.Decimal(-0.00400250009343);
|
|
66
|
+
console.log(a.value, a.multiplyByPowerOfTen(power).toTree().toTex());
|
|
67
|
+
const b = new decimal_1.Decimal(0.04010009343);
|
|
68
|
+
console.log(b.value, b.multiplyByPowerOfTen(power).toTree().toTex());
|
|
69
|
+
const c = new decimal_1.Decimal(-23.00009343);
|
|
70
|
+
console.log(c.value, c.multiplyByPowerOfTen(power).toTree().toTex());
|
|
71
|
+
const d = new decimal_1.Decimal(20.4009343);
|
|
72
|
+
console.log(d.value, d.multiplyByPowerOfTen(power).toTree().toTex());
|
|
51
73
|
app.get("/", (req, res) => {
|
|
52
74
|
res.json(allExercises);
|
|
53
75
|
});
|
|
@@ -19,7 +19,7 @@ export declare class OppositeNode implements FunctionNode {
|
|
|
19
19
|
*/
|
|
20
20
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
21
21
|
evaluate(vars: Record<string, number>): number;
|
|
22
|
-
simplify(opts?: SimplifyOptions):
|
|
22
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
23
23
|
equals(node: AlgebraicNode): boolean;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=oppositeNode.d.ts.map
|
|
@@ -6,6 +6,7 @@ const node_1 = require("../node");
|
|
|
6
6
|
const operatorNode_1 = require("../operators/operatorNode");
|
|
7
7
|
const functionNode_1 = require("./functionNode");
|
|
8
8
|
const numberNode_1 = require("../numbers/numberNode");
|
|
9
|
+
const multiplyNode_1 = require("../operators/multiplyNode");
|
|
9
10
|
const fractionNode_1 = require("../operators/fractionNode");
|
|
10
11
|
function isOppositeNode(a) {
|
|
11
12
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.opposite;
|
|
@@ -70,7 +71,7 @@ class OppositeNode {
|
|
|
70
71
|
return -this.child.evaluate(vars);
|
|
71
72
|
}
|
|
72
73
|
simplify(opts) {
|
|
73
|
-
return new
|
|
74
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(-1), this.child).simplify(opts);
|
|
74
75
|
}
|
|
75
76
|
equals(node) {
|
|
76
77
|
return isOppositeNode(node) && node.child.equals(this.child);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOlE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,iBAAiB;IAqBjB,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAuBf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA+FrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;
|
|
1
|
+
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOlE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,iBAAiB;IAqBjB,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAuBf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA+FrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAY/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC;AAED,qBAAa,UAAW,SAAQ,SAAS;gBAC3B,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;CAGrD"}
|
|
@@ -157,11 +157,14 @@ class PowerNode {
|
|
|
157
157
|
// // puissances négatives ?
|
|
158
158
|
// }
|
|
159
159
|
simplify(opts) {
|
|
160
|
+
const leftSimplified = this.leftChild.simplify(opts);
|
|
161
|
+
const rightSimplified = this.rightChild.simplify(opts);
|
|
162
|
+
const copy = new PowerNode(leftSimplified, rightSimplified, this.opts);
|
|
160
163
|
//! temporaire
|
|
161
|
-
if ((0, numberNode_1.isNumberNode)(
|
|
162
|
-
return new multiplyNode_1.MultiplyNode(
|
|
164
|
+
if ((0, numberNode_1.isNumberNode)(copy.rightChild) && copy.rightChild.value === 2) {
|
|
165
|
+
return new multiplyNode_1.MultiplyNode(copy.leftChild, copy.leftChild).simplify(opts);
|
|
163
166
|
}
|
|
164
|
-
return
|
|
167
|
+
return copy;
|
|
165
168
|
}
|
|
166
169
|
equals(node) {
|
|
167
170
|
return (isPowerNode(node) &&
|
|
@@ -43,7 +43,7 @@ class SubstractNode {
|
|
|
43
43
|
[operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(this.rightChild.id)) ||
|
|
44
44
|
rightTex[0] === "-";
|
|
45
45
|
if (needBrackets)
|
|
46
|
-
rightTex =
|
|
46
|
+
rightTex = `\\left(${rightTex}\\right)`;
|
|
47
47
|
return `${leftTex}-${rightTex}`;
|
|
48
48
|
}
|
|
49
49
|
evaluate(vars) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0CvD,eAAO,MAAM,QAAQ,UAAW,MAAM,aA4BrC,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,kBAavC,CAAC"}
|