math-exercises 2.2.65 → 2.2.67
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/math/calcul/fractions/fractionAndIntegerSum.d.ts +1 -0
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.js +51 -37
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +8 -3
- package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +1 -1
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +122 -0
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts +9 -3
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +64 -17
- package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.js +1 -1
- package/lib/exercises/math/functions/trinoms/coefficientsIdentification.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/coefficientsIdentification.js +8 -3
- package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.js +3 -1
- package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.js +1 -2
- package/lib/exercises/math/geometry/cartesian/placeAPoint.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAPoint.js +1 -2
- package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.js +1 -2
- package/lib/exercises/math/geometry/vectors/drawAVectorInGGB.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/drawAVectorInGGB.js +1 -2
- package/lib/exercises/math/percent/applyPercent.d.ts.map +1 -1
- package/lib/exercises/math/percent/applyPercent.js +2 -4
- package/lib/exercises/math/probaStat/probabilityTree.d.ts +10 -7
- package/lib/exercises/math/probaStat/probabilityTree.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probabilityTree.js +194 -90
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +7 -3
- package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootIdentities.js +5 -1
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +5 -1
- package/lib/exercises/pc/calibrationCurveOfSolution.d.ts.map +1 -1
- package/lib/exercises/pc/calibrationCurveOfSolution.js +1 -2
- package/lib/exercises/vea/rationalVEA.d.ts +7 -1
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/rationalVEA.js +34 -4
- package/lib/index.d.ts +24 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/math/complex/complex.d.ts +1 -1
- package/lib/math/numbers/rationals/rational.d.ts +1 -1
- package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
- package/lib/math/polynomials/generalAffine.d.ts +10 -0
- package/lib/math/polynomials/generalAffine.d.ts.map +1 -0
- package/lib/math/polynomials/generalAffine.js +32 -0
- package/lib/math/polynomials/generalTrinom.d.ts +1 -1
- package/lib/math/polynomials/trinom.d.ts +3 -3
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +2 -3
- package/lib/prototypesEnhancement.d.ts +3 -1
- package/lib/prototypesEnhancement.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.d.ts +13 -9
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +17 -1
- package/lib/tree/nodes/functions/absNode.d.ts +1 -1
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts +8 -9
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +15 -0
- package/lib/tree/parsers/affineParser.d.ts +1 -2
- package/lib/tree/parsers/affineParser.d.ts.map +1 -1
- package/lib/tree/parsers/affineParser.js +22 -17
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +34 -9
- package/lib/tree/parsers/monomParser.d.ts +9 -1
- package/lib/tree/parsers/monomParser.d.ts.map +1 -1
- package/lib/tree/parsers/monomParser.js +65 -2
- package/lib/tree/parsers/powerParser.d.ts +1 -1
- package/lib/tree/parsers/purifyLatex.d.ts +9 -0
- package/lib/tree/parsers/purifyLatex.d.ts.map +1 -0
- package/lib/tree/parsers/purifyLatex.js +17 -0
- package/lib/tree/parsers/rationalParser.d.ts +1 -1
- package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
- package/lib/tree/parsers/trinomParser.d.ts +2 -0
- package/lib/tree/parsers/trinomParser.d.ts.map +1 -0
- package/lib/tree/parsers/trinomParser.js +31 -0
- package/package.json +1 -1
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare class Complex {
|
|
|
18
18
|
times(n: number): Complex;
|
|
19
19
|
opposite(): Complex;
|
|
20
20
|
conjugate(): Complex;
|
|
21
|
-
toArgumentTree(): NumberNode | import("../../tree/nodes/numbers/constantNode").ConstantNode |
|
|
21
|
+
toArgumentTree(): NumberNode | import("../../tree/nodes/numbers/constantNode").ConstantNode | OppositeNode | FractionNode | undefined;
|
|
22
22
|
toModuleTree(): import("../../tree/nodes/algebraicNode").AlgebraicNode;
|
|
23
23
|
toTree(): ComplexNode;
|
|
24
24
|
}
|
|
@@ -28,7 +28,7 @@ export declare class Rational implements Nombre {
|
|
|
28
28
|
reverse(shouldSimplify: boolean): Nombre;
|
|
29
29
|
divide(nb: Nombre): Nombre;
|
|
30
30
|
opposite(): Rational;
|
|
31
|
-
toTree(opts?: NodeOptions):
|
|
31
|
+
toTree(opts?: NodeOptions): OppositeNode | FractionNode;
|
|
32
32
|
isIrreductible(): boolean;
|
|
33
33
|
simplify(): Integer | Rational;
|
|
34
34
|
}
|
|
@@ -13,6 +13,6 @@ export declare class ExtendedRingElement {
|
|
|
13
13
|
b: number;
|
|
14
14
|
algebraicElement: Nombre;
|
|
15
15
|
constructor(a: number, b: number, algebraicElement: Nombre);
|
|
16
|
-
toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode |
|
|
16
|
+
toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | SubstractNode | AddNode | OppositeNode | MultiplyNode;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=extendedRingElement.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
+
export declare class GeneralAffine {
|
|
3
|
+
a: AlgebraicNode;
|
|
4
|
+
b: AlgebraicNode;
|
|
5
|
+
variable: string;
|
|
6
|
+
constructor(a: number | AlgebraicNode, b: number | AlgebraicNode, variable?: string);
|
|
7
|
+
getRoot(): AlgebraicNode;
|
|
8
|
+
toTree(): import("../../tree/nodes/operators/addNode").AddNode | import("../../tree/nodes/operators/multiplyNode").MultiplyNode;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=generalAffine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generalAffine.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/generalAffine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,qBAAa,aAAa;IACxB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;gBAGf,CAAC,EAAE,MAAM,GAAG,aAAa,EACzB,CAAC,EAAE,MAAM,GAAG,aAAa,EACzB,QAAQ,GAAE,MAAY;IAWxB,OAAO,IAAI,aAAa;IAIxB,MAAM;CAKP"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeneralAffine = void 0;
|
|
4
|
+
const oppositeNode_1 = require("../../tree/nodes/functions/oppositeNode");
|
|
5
|
+
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
6
|
+
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
7
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
8
|
+
class GeneralAffine {
|
|
9
|
+
constructor(a, b, variable = "x") {
|
|
10
|
+
if (typeof a === "number")
|
|
11
|
+
this.a = a.toTree();
|
|
12
|
+
else
|
|
13
|
+
this.a = a;
|
|
14
|
+
if (this.a.evaluate() === 0)
|
|
15
|
+
throw new Error("Forbidden division by zero");
|
|
16
|
+
if (typeof b === "number")
|
|
17
|
+
this.b = b.toTree();
|
|
18
|
+
else
|
|
19
|
+
this.b = b;
|
|
20
|
+
this.variable = variable;
|
|
21
|
+
}
|
|
22
|
+
getRoot() {
|
|
23
|
+
return (0, fractionNode_1.frac)((0, oppositeNode_1.opposite)(this.b), this.a).simplify();
|
|
24
|
+
}
|
|
25
|
+
toTree() {
|
|
26
|
+
const monom = (0, multiplyNode_1.multiply)(this.a, this.variable);
|
|
27
|
+
if (this.b.evaluate() === 0)
|
|
28
|
+
return monom;
|
|
29
|
+
return (0, addNode_1.add)(monom, this.b);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.GeneralAffine = GeneralAffine;
|
|
@@ -51,7 +51,7 @@ export declare class GeneralTrinom {
|
|
|
51
51
|
constructor(a: AlgebraicNode | number, b: AlgebraicNode | number, c: AlgebraicNode | number, opts?: GeneralTrinomOptions);
|
|
52
52
|
getDelta(): AlgebraicNode;
|
|
53
53
|
getRoots(): AlgebraicNode[];
|
|
54
|
-
toTree(): import("../../tree/nodes/operators/
|
|
54
|
+
toTree(): import("../../tree/nodes/operators/addNode").AddNode | import("../../tree/nodes/operators/multiplyNode").MultiplyNode;
|
|
55
55
|
toTex(): string;
|
|
56
56
|
getCoeffs(): number[];
|
|
57
57
|
toIdentifiers(): GeneralTrinomIdentifiers;
|
|
@@ -65,11 +65,11 @@ export declare class Trinom extends Polynomial {
|
|
|
65
65
|
getRootsNode(): AlgebraicNode[];
|
|
66
66
|
getRootsEquationSolutionTex(): string;
|
|
67
67
|
getAlpha(): number;
|
|
68
|
-
getAlphaNode(): NumberNode |
|
|
68
|
+
getAlphaNode(): NumberNode | OppositeNode | FractionNode;
|
|
69
69
|
getBeta(): number;
|
|
70
|
-
getBetaNode(): NumberNode |
|
|
70
|
+
getBetaNode(): NumberNode | OppositeNode | FractionNode;
|
|
71
71
|
getFactorizedForm(): AlgebraicNode | MultiplyNode;
|
|
72
|
-
getCanonicalForm():
|
|
72
|
+
getCanonicalForm(): AddNode | MultiplyNode;
|
|
73
73
|
getSommet(): Point;
|
|
74
74
|
getCoords(): number[];
|
|
75
75
|
toPython(): string;
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,UAAU,YAEtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playground = void 0;
|
|
4
4
|
const nodeConstructor_1 = require("./tree/nodes/nodeConstructor");
|
|
5
|
+
const affineParser_1 = require("./tree/parsers/affineParser");
|
|
5
6
|
const playground = () => {
|
|
6
|
-
|
|
7
|
-
// const parsed = parseLatex("^{^3}");
|
|
8
|
-
// console.log(parsed.toTex());
|
|
7
|
+
console.log((0, affineParser_1.affineParser)("8"));
|
|
9
8
|
};
|
|
10
9
|
exports.playground = playground;
|
|
11
10
|
const logIdentifiers = () => {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AlgebraicNode } from "./tree/nodes/algebraicNode";
|
|
2
2
|
import { NodeOptions } from "./tree/nodes/node";
|
|
3
|
+
import { ConstantNode } from "./tree/nodes/numbers/constantNode";
|
|
4
|
+
import { NumberNode } from "./tree/nodes/numbers/numberNode";
|
|
3
5
|
declare global {
|
|
4
6
|
interface Number {
|
|
5
|
-
toTree: (opts?: NodeOptions) =>
|
|
7
|
+
toTree: (opts?: NodeOptions) => NumberNode | ConstantNode;
|
|
6
8
|
frenchify: () => string;
|
|
7
9
|
toScientific: (decimals?: number) => AlgebraicNode;
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototypesEnhancement.d.ts","sourceRoot":"","sources":["../src/prototypesEnhancement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAQ,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"prototypesEnhancement.d.ts","sourceRoot":"","sources":["../src/prototypesEnhancement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAQ,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAKjE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU,GAAG,YAAY,CAAC;QAC1D,SAAS,EAAE,MAAM,MAAM,CAAC;QACxB,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;KACpD;IACD,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,aAAa,CAAC;QAC5B,WAAW,EAAE,MAAM,MAAM,CAAC;KAC3B;CACF;AAqBD,OAAO,EAAE,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../algebraicNode";
|
|
2
2
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node";
|
|
3
|
+
import { NodeIdentifiers } from "../nodeConstructor";
|
|
3
4
|
export declare const equal: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => EqualNode;
|
|
5
|
+
export type EqualNodeIdentifiers = {
|
|
6
|
+
id: NodeIds.equal;
|
|
7
|
+
leftChild: NodeIdentifiers;
|
|
8
|
+
rightChild: NodeIdentifiers;
|
|
9
|
+
opts?: NodeOptions;
|
|
10
|
+
};
|
|
11
|
+
export declare abstract class EqualNodeConstructor {
|
|
12
|
+
static fromIdentifiers(identifiers: EqualNodeIdentifiers): EqualNode;
|
|
13
|
+
}
|
|
4
14
|
export declare const isEqualNode: (node: Node) => node is EqualNode;
|
|
5
15
|
export declare class EqualNode implements Node {
|
|
6
16
|
leftChild: Node;
|
|
@@ -8,19 +18,13 @@ export declare class EqualNode implements Node {
|
|
|
8
18
|
opts?: NodeOptions;
|
|
9
19
|
type: NodeType;
|
|
10
20
|
constructor(leftChild: Node, rightChild: Node, opts?: NodeOptions);
|
|
11
|
-
toIdentifiers():
|
|
12
|
-
id: NodeIds;
|
|
13
|
-
leftChild: {
|
|
14
|
-
id: NodeIds;
|
|
15
|
-
} & Record<string, any>;
|
|
16
|
-
rightChild: {
|
|
17
|
-
id: NodeIds;
|
|
18
|
-
} & Record<string, any>;
|
|
19
|
-
};
|
|
21
|
+
toIdentifiers(): EqualNodeIdentifiers;
|
|
20
22
|
toEquivalentNodes(opts?: NodeOptions): Node[];
|
|
21
23
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
22
24
|
toMathString(): string;
|
|
23
25
|
toTex(): string;
|
|
24
26
|
simplify(): this;
|
|
27
|
+
shuffle(): EqualNode;
|
|
28
|
+
reverse(): EqualNode;
|
|
25
29
|
}
|
|
26
30
|
//# sourceMappingURL=equalNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equalNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/equalNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"equalNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/equalNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAmB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEtE,eAAO,MAAM,KAAK,MACb,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,cAOnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;IAClB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;IAC5B,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,8BAAsB,oBAAoB;IACxC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,oBAAoB,GAAG,SAAS;CAOrE;AAED,eAAO,MAAM,WAAW,SAAU,IAAI,sBACL,CAAC;AAElC,qBAAa,SAAU,YAAW,IAAI;IACpC,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;gBACH,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,WAAW;IAOjE,aAAa,IAAI,oBAAoB;IAQrC,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAmBpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAM5C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAIf,QAAQ;IAIR,OAAO;IAIP,OAAO;CAUR"}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EqualNode = exports.isEqualNode = exports.equal = void 0;
|
|
3
|
+
exports.EqualNode = exports.isEqualNode = exports.EqualNodeConstructor = exports.equal = void 0;
|
|
4
|
+
// import { equal } from "mathjs";
|
|
5
|
+
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
4
6
|
const node_1 = require("../node");
|
|
7
|
+
const nodeConstructor_1 = require("../nodeConstructor");
|
|
5
8
|
const equal = (a, b) => {
|
|
6
9
|
const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
|
|
7
10
|
const nodeB = typeof b === "number" ? b.toTree() : typeof b === "string" ? b.toTree() : b;
|
|
8
11
|
return new EqualNode(nodeA, nodeB);
|
|
9
12
|
};
|
|
10
13
|
exports.equal = equal;
|
|
14
|
+
class EqualNodeConstructor {
|
|
15
|
+
static fromIdentifiers(identifiers) {
|
|
16
|
+
return new EqualNode(nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.leftChild), nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.rightChild), identifiers.opts);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.EqualNodeConstructor = EqualNodeConstructor;
|
|
11
20
|
const isEqualNode = (node) => node.type === node_1.NodeType.equality;
|
|
12
21
|
exports.isEqualNode = isEqualNode;
|
|
13
22
|
class EqualNode {
|
|
@@ -22,6 +31,7 @@ class EqualNode {
|
|
|
22
31
|
id: node_1.NodeIds.equal,
|
|
23
32
|
leftChild: this.leftChild.toIdentifiers(),
|
|
24
33
|
rightChild: this.rightChild.toIdentifiers(),
|
|
34
|
+
opts: this.opts,
|
|
25
35
|
};
|
|
26
36
|
}
|
|
27
37
|
toEquivalentNodes(opts) {
|
|
@@ -53,5 +63,11 @@ class EqualNode {
|
|
|
53
63
|
simplify() {
|
|
54
64
|
return this;
|
|
55
65
|
}
|
|
66
|
+
shuffle() {
|
|
67
|
+
return (0, coinFlip_1.coinFlip)() ? this : this.reverse();
|
|
68
|
+
}
|
|
69
|
+
reverse() {
|
|
70
|
+
return new EqualNode(this.rightChild, this.leftChild, this.opts);
|
|
71
|
+
}
|
|
56
72
|
}
|
|
57
73
|
exports.EqualNode = EqualNode;
|
|
@@ -18,7 +18,7 @@ export declare class AbsNode implements FunctionNode {
|
|
|
18
18
|
toTex(): string;
|
|
19
19
|
toEquivalentNodes(): AlgebraicNode[];
|
|
20
20
|
toAllValidTexs(): string[];
|
|
21
|
-
simplify(): AlgebraicNode | AbsNode;
|
|
21
|
+
simplify(): AlgebraicNode | import("../numbers/numberNode").NumberNode | import("../numbers/constantNode").ConstantNode | AbsNode;
|
|
22
22
|
evaluate(vars?: Record<string, number>): number;
|
|
23
23
|
equals(node: AlgebraicNode): boolean;
|
|
24
24
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): AbsNode;
|
|
@@ -22,7 +22,7 @@ export declare class InequationSolutionNode implements Node {
|
|
|
22
22
|
};
|
|
23
23
|
toAllTexs(): string[];
|
|
24
24
|
toAllValidTexs(): string[];
|
|
25
|
-
toEquivalentNodes(opts?: NodeOptions): (
|
|
25
|
+
toEquivalentNodes(opts?: NodeOptions): (import("./inequationNode").InequationNode | InequationSolutionNode)[];
|
|
26
26
|
toMathString(): string;
|
|
27
27
|
toMathjs(): string;
|
|
28
28
|
toTex(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,uBA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AAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAoQ/C,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAUpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CAMzD"}
|
|
@@ -14,6 +14,7 @@ const numberNode_1 = require("../numbers/numberNode");
|
|
|
14
14
|
const multiplyNode_1 = require("./multiplyNode");
|
|
15
15
|
const fractionNode_1 = require("./fractionNode");
|
|
16
16
|
const colorize_1 = require("../../../utils/latex/colorize");
|
|
17
|
+
const round_1 = require("../../../math/utils/round");
|
|
17
18
|
function isAddNode(a) {
|
|
18
19
|
return (0, operatorNode_1.isOperatorNode)(a) && a.id === operatorNode_1.OperatorIds.add;
|
|
19
20
|
}
|
|
@@ -203,7 +204,7 @@ class AddNode {
|
|
|
203
204
|
return new fractionNode_1.FractionNode(new AddNode(new oppositeNode_1.OppositeNode(c), new multiplyNode_1.MultiplyNode(d, a)), d).simplify(opts);
|
|
204
205
|
}
|
|
205
206
|
if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
|
|
206
|
-
return new numberNode_1.NumberNode(a.value + b.value);
|
|
207
|
+
return new numberNode_1.NumberNode((0, round_1.round)(a.value + b.value, 12));
|
|
207
208
|
}
|
|
208
209
|
if ((0, oppositeNode_1.isOppositeNode)(a) && (0, numberNode_1.isNumberNode)(a.child) && (0, numberNode_1.isNumberNode)(b)) {
|
|
209
210
|
return new numberNode_1.NumberNode(-a.child.value + b.value);
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
|
+
import { NodeIdentifiers } from "../nodeConstructor";
|
|
4
5
|
export declare function isFractionNode(a: Node): a is FractionNode;
|
|
5
6
|
export declare const frac: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => FractionNode;
|
|
7
|
+
export type FractionNodeIdentifiers = {
|
|
8
|
+
id: NodeIds.fraction;
|
|
9
|
+
leftChild: NodeIdentifiers;
|
|
10
|
+
rightChild: NodeIdentifiers;
|
|
11
|
+
};
|
|
6
12
|
export declare class FractionNode implements OperatorNode {
|
|
7
13
|
opts?: NodeOptions;
|
|
8
14
|
/**
|
|
@@ -16,18 +22,11 @@ export declare class FractionNode implements OperatorNode {
|
|
|
16
22
|
isNumeric: boolean;
|
|
17
23
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
18
24
|
toMathString(): string;
|
|
19
|
-
toIdentifiers():
|
|
20
|
-
id: NodeIds;
|
|
21
|
-
leftChild: {
|
|
22
|
-
id: NodeIds;
|
|
23
|
-
} & Record<string, any>;
|
|
24
|
-
rightChild: {
|
|
25
|
-
id: NodeIds;
|
|
26
|
-
} & Record<string, any>;
|
|
27
|
-
};
|
|
25
|
+
toIdentifiers(): FractionNodeIdentifiers;
|
|
28
26
|
toInversed(): FractionNode;
|
|
29
27
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
30
28
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
29
|
+
isDecimal(): boolean;
|
|
31
30
|
toTex(): string;
|
|
32
31
|
evaluate(vars?: Record<string, number>): number;
|
|
33
32
|
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AA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,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AACF,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,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;IAiBpB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,uBAAuB;IAQxC,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,SAAS;IAUT,KAAK,IAAI,MAAM;IAsBf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAyJ/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAOxD,sBAAsB;CAQvB"}
|
|
@@ -77,6 +77,21 @@ class FractionNode {
|
|
|
77
77
|
toAllValidTexs(opts) {
|
|
78
78
|
return this.toEquivalentNodes(opts).map((node) => node.toTex());
|
|
79
79
|
}
|
|
80
|
+
isDecimal() {
|
|
81
|
+
if (!(0, numberNode_1.isNumberNode)(this.leftChild))
|
|
82
|
+
return false;
|
|
83
|
+
if (!(0, numberNode_1.isNumberNode)(this.rightChild))
|
|
84
|
+
return false;
|
|
85
|
+
const simp = this.simplify();
|
|
86
|
+
if ((0, numberNode_1.isNumberNode)(simp))
|
|
87
|
+
return true;
|
|
88
|
+
let denum = simp.leftChild.evaluate();
|
|
89
|
+
while (denum % 2 === 0)
|
|
90
|
+
denum = denum / 2;
|
|
91
|
+
while (denum % 5 === 0)
|
|
92
|
+
denum = denum / 5;
|
|
93
|
+
return denum === 1;
|
|
94
|
+
}
|
|
80
95
|
toTex() {
|
|
81
96
|
if (!this.opts?.allowMinusAnywhereInFraction &&
|
|
82
97
|
((0, oppositeNode_1.isOppositeNode)(this.leftChild) ||
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const affineParser: (ans: string, variable?: string) => false | import("../nodes/variables/variableNode").VariableNode | Affine | undefined;
|
|
1
|
+
export declare const affineParser: (ans: string, variable?: string) => false | import("../nodes/algebraicNode").AlgebraicNode | import("../nodes/operators/substractNode").SubstractNode | import("../nodes/operators/addNode").AddNode;
|
|
3
2
|
//# sourceMappingURL=affineParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/affineParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"affineParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/affineParser.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,QAAS,MAAM,aAAY,MAAM,qKAqBzD,CAAC"}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.affineParser = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const multiplyNode_1 = require("../nodes/operators/multiplyNode");
|
|
7
|
-
const variableNode_1 = require("../nodes/variables/variableNode");
|
|
4
|
+
const addNode_1 = require("../nodes/operators/addNode");
|
|
5
|
+
const substractNode_1 = require("../nodes/operators/substractNode");
|
|
8
6
|
const latexParser_1 = require("./latexParser");
|
|
7
|
+
const monomParser_1 = require("./monomParser");
|
|
9
8
|
const affineParser = (ans, variable = "x") => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
try {
|
|
10
|
+
const monom = (0, monomParser_1.monomParser)(ans, { variable, maxDegree: 1 });
|
|
11
|
+
if (monom)
|
|
12
|
+
return monom;
|
|
13
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
14
|
+
if ((0, addNode_1.isAddNode)(parsed) || (0, substractNode_1.isSubstractNode)(parsed)) {
|
|
15
|
+
const numericChild = parsed.leftChild.isNumeric
|
|
16
|
+
? "left"
|
|
17
|
+
: parsed.rightChild.isNumeric
|
|
18
|
+
? "right"
|
|
19
|
+
: undefined;
|
|
20
|
+
if (!numericChild)
|
|
21
|
+
return false;
|
|
22
|
+
const varChild = numericChild === "left" ? parsed.rightChild : parsed.leftChild;
|
|
23
|
+
return (0, monomParser_1.isMonomNode)(varChild, { variable, maxDegree: 1 }) ? parsed : false;
|
|
22
24
|
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return false;
|
|
23
29
|
}
|
|
24
|
-
//"x" ou a*x ou a*x+b ou x+b
|
|
25
30
|
};
|
|
26
31
|
exports.affineParser = affineParser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAkDrE,eAAO,MAAM,QAAQ,UAAW,MAAM,aA4BrC,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,MAAM,kBAa3C,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,+CA2CvC,CAAC"}
|
|
@@ -26,7 +26,9 @@ const functions = [
|
|
|
26
26
|
const operators = ["+", "-", "\\div", "\\times", "^"];
|
|
27
27
|
//cmds childless, like \\pi
|
|
28
28
|
const symbols = [{ tex: "\\pi", node: piNode_1.PiNode }];
|
|
29
|
+
//separators between trees
|
|
29
30
|
const separators = ["=", "<", ">", "\\leq", "\\geq"];
|
|
31
|
+
//le nombre de parentheses est il respecté
|
|
30
32
|
const isDyck = (tokens) => {
|
|
31
33
|
const brackets = tokens.filter((el) => el === "(" || el === ")");
|
|
32
34
|
while (brackets.length) {
|
|
@@ -47,6 +49,8 @@ const isDyck = (tokens) => {
|
|
|
47
49
|
}
|
|
48
50
|
return true;
|
|
49
51
|
};
|
|
52
|
+
//?on push les nb, commands, variables, symboles dans un array de token
|
|
53
|
+
//?ex [3 ; + ; \\pi ; \\frac ; { ; 2 ; x ; } ; { 3 ; x ; }]
|
|
50
54
|
const tokenize = (latex) => {
|
|
51
55
|
const tokens = [];
|
|
52
56
|
for (let i = 0; i < latex.length; i++) {
|
|
@@ -136,6 +140,9 @@ const parseLatex = (latex) => {
|
|
|
136
140
|
}
|
|
137
141
|
};
|
|
138
142
|
exports.parseLatex = parseLatex;
|
|
143
|
+
//? parcours en profondeur dans le sens où profondeur = ouverture d'un sous arbre math
|
|
144
|
+
//? genre dans 3exp(x^2) , x^2 est à la profondeur 2 et ^2 est pronfondeur 3
|
|
145
|
+
//
|
|
139
146
|
const buildTree = (tokens) => {
|
|
140
147
|
let currentDepth = 0;
|
|
141
148
|
let maxDepth = 0;
|
|
@@ -152,7 +159,14 @@ const buildTree = (tokens) => {
|
|
|
152
159
|
if (token === ")" || token === "}")
|
|
153
160
|
currentDepth--;
|
|
154
161
|
}
|
|
155
|
-
|
|
162
|
+
//? on parcours en partant de profondeur max, pour chaque profondeur on build le tree de l'expression
|
|
163
|
+
//? ce tree remplace les tokens de cette profondeur
|
|
164
|
+
//? donc 3exp(x^2)
|
|
165
|
+
//? -> via tokenize : [3, exp, x, ^, 2]
|
|
166
|
+
//? -> to depthed: [{3, 0}, {exp, 0}, {x, 1}, {^, 1}, {2, 2}]
|
|
167
|
+
//? -> itération 1 : [{3, 0}, {exp, 0}, {x, 1}, {^, 1}, {NumberNode(2), 1}]
|
|
168
|
+
//? -> itération 2 : [{3, 0}, {exp, 0}, {SquareNode(x), 1}]
|
|
169
|
+
//? -> itération 3 : Multiply(3, ExpNode(SquareNode(x)))
|
|
156
170
|
while (true) {
|
|
157
171
|
if (maxDepth === 0) {
|
|
158
172
|
const tree = buildTreeForSameDepthTokens(depthedTokens.map((el) => el.token));
|
|
@@ -160,30 +174,33 @@ const buildTree = (tokens) => {
|
|
|
160
174
|
}
|
|
161
175
|
for (let i = 0; i < depthedTokens.length; i++) {
|
|
162
176
|
const token = depthedTokens[i];
|
|
177
|
+
//? on commence par les tokens de depth max
|
|
163
178
|
if (token.depth < maxDepth)
|
|
164
179
|
continue;
|
|
165
|
-
|
|
166
|
-
|
|
180
|
+
//? le token est forcément ici ( ou {
|
|
181
|
+
//? et on est sur qu'il n'y a aucun autre nestage à l'intérieur
|
|
167
182
|
const endIndex = depthedTokens.findIndex((el, index) => index > i && (el.token === ")" || el.token === "}"));
|
|
168
183
|
const tree = buildTreeForSameDepthTokens(depthedTokens.slice(i + 1, endIndex).map((el) => el.token));
|
|
169
184
|
depthedTokens.splice(i, endIndex - i + 1, {
|
|
170
185
|
token: tree,
|
|
171
186
|
depth: token.depth - 1,
|
|
172
187
|
});
|
|
173
|
-
// console.log(`depthed after iter ${i}`, depthedTokens);
|
|
174
188
|
}
|
|
175
189
|
maxDepth--;
|
|
176
190
|
}
|
|
177
191
|
};
|
|
178
192
|
const buildTreeForSameDepthTokens = (tokens) => {
|
|
179
|
-
|
|
193
|
+
//? à ce stade les tokens sont soit des charactères soit des nodes déjà build (par buildTree)
|
|
194
|
+
//? ici on n'est dans une profondeur unique
|
|
180
195
|
let tempTokens = [];
|
|
181
196
|
for (let i = 0; i < tokens.length; i++) {
|
|
182
197
|
const token = tokens[i];
|
|
198
|
+
//?buildTree a déjà pu build des expressions de profondeur plus grande
|
|
183
199
|
if (typeof token !== "string") {
|
|
184
200
|
tempTokens[i] = token;
|
|
185
201
|
continue;
|
|
186
202
|
}
|
|
203
|
+
//? les nombres, variables et symboles (pi) sont direct push en node
|
|
187
204
|
if (token[0].match(/[0-9]/)) {
|
|
188
205
|
tempTokens[i] = new numberNode_1.NumberNode(Number(token));
|
|
189
206
|
}
|
|
@@ -203,8 +220,7 @@ const buildTreeForSameDepthTokens = (tokens) => {
|
|
|
203
220
|
else
|
|
204
221
|
throw Error(`token not implemented: ${token}`);
|
|
205
222
|
}
|
|
206
|
-
|
|
207
|
-
//1 build les fct
|
|
223
|
+
//?1 build les fct
|
|
208
224
|
for (let i = 0; i < tempTokens.length; i++) {
|
|
209
225
|
if (typeof tempTokens[i] !== "string")
|
|
210
226
|
continue;
|
|
@@ -223,7 +239,6 @@ const buildTreeForSameDepthTokens = (tokens) => {
|
|
|
223
239
|
}
|
|
224
240
|
}
|
|
225
241
|
if (token === "^") {
|
|
226
|
-
console.log(tempTokens[i - 1]);
|
|
227
242
|
if (!tempTokens[i - 1] ||
|
|
228
243
|
typeof tempTokens[i - 1] === "string" ||
|
|
229
244
|
!tempTokens[i + 1] ||
|
|
@@ -312,7 +327,17 @@ const buildTreeForSameDepthTokens = (tokens) => {
|
|
|
312
327
|
const token = tempTokens[i];
|
|
313
328
|
if (!currentAdd) {
|
|
314
329
|
if (typeof token === "string") {
|
|
315
|
-
|
|
330
|
+
//ici on accepte +3 (mais seulement en début de tree)
|
|
331
|
+
//donc +3 + X est ok
|
|
332
|
+
//mais pas x \\times +3
|
|
333
|
+
if (token === "+" &&
|
|
334
|
+
!!tempTokens[i + 1] &&
|
|
335
|
+
typeof tempTokens[i + 1] !== "string" &&
|
|
336
|
+
(0, numberNode_1.isNumberNode)(tempTokens[i + 1])) {
|
|
337
|
+
currentAdd = tempTokens[i + 1];
|
|
338
|
+
i++;
|
|
339
|
+
}
|
|
340
|
+
else if (token === "+" || token === "-") {
|
|
316
341
|
throw Error("Addition with no first term");
|
|
317
342
|
}
|
|
318
343
|
else
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { AlgebraicNode } from "../nodes/algebraicNode";
|
|
2
|
+
type Opts = {
|
|
3
|
+
variable: string;
|
|
4
|
+
maxDegree?: number;
|
|
5
|
+
minDegree?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const monomParser: (str: string, { variable, maxDegree, minDegree }?: Opts) => false | AlgebraicNode;
|
|
8
|
+
export declare const isMonomNode: (node: AlgebraicNode, { variable, maxDegree, minDegree }?: Opts) => boolean;
|
|
9
|
+
export {};
|
|
2
10
|
//# sourceMappingURL=monomParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/monomParser.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"monomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/monomParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQvD,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,WAAW,QACjB,MAAM,uCACyB,IAAI,0BAkBzC,CAAC;AAEF,eAAO,MAAM,WAAW,SAChB,aAAa,uCACiB,IAAI,YAsCzC,CAAC"}
|