math-exercises 2.2.81 → 2.2.83
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/calculLitteral/inequations/firstDegreeInequationsType2.d.ts +4 -1
- package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType2.js +79 -30
- package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts +4 -1
- package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.js +89 -39
- package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.js +37 -17
- package/lib/exercises/math/calculLitteral/simplifying/evaluateExpression.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/evaluateExpression.js +55 -15
- package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.js +9 -18
- package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.js +11 -11
- package/lib/exercises/math/functions/absolute/absolueValueInequationsSup.d.ts.map +1 -1
- package/lib/exercises/math/functions/absolute/absolueValueInequationsSup.js +10 -2
- package/lib/exercises/math/functions/absolute/absoluteValueInequations.d.ts.map +1 -1
- package/lib/exercises/math/functions/absolute/absoluteValueInequations.js +11 -4
- package/lib/exercises/math/functions/basics/graphicEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/graphicEquation.js +46 -28
- package/lib/exercises/math/functions/basics/graphicInequation.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/graphicInequation.js +0 -1
- package/lib/exercises/math/functions/basics/graphicInequationAffine.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/graphicInequationAffine.js +10 -3
- package/lib/exercises/math/functions/basics/twoFunctionsInequation.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/twoFunctionsInequation.js +74 -58
- package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +1 -0
- package/lib/exercises/math/functions/square/squareImageInterval.d.ts.map +1 -1
- package/lib/exercises/math/functions/square/squareImageInterval.js +13 -4
- package/lib/exercises/math/functions/trinoms/secondDegreeInequation.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/secondDegreeInequation.js +10 -6
- package/lib/exercises/math/functions/trinoms/trinomSignFromRoots.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/trinomSignFromRoots.js +12 -6
- package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.d.ts.map +1 -1
- package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +9 -14
- package/lib/exercises/math/matrices/matrixInversibilityDomain.d.ts.map +1 -1
- package/lib/exercises/math/matrices/matrixInversibilityDomain.js +15 -2
- package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts.map +1 -1
- package/lib/exercises/math/python/pyForLoop1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/sequences/genericSequenceVariations.d.ts.map +1 -1
- package/lib/exercises/math/sets/intervals/inequalityToInterval.d.ts +2 -4
- package/lib/exercises/math/sets/intervals/inequalityToInterval.d.ts.map +1 -1
- package/lib/exercises/math/sets/intervals/inequalityToInterval.js +30 -25
- package/lib/exercises/math/sets/intervals/intervalToInequality.d.ts +2 -4
- package/lib/exercises/math/sets/intervals/intervalToInequality.d.ts.map +1 -1
- package/lib/exercises/math/sets/intervals/intervalToInequality.js +42 -78
- package/lib/exercises/math/sets/intervals/intervalsIntersection.d.ts +3 -7
- package/lib/exercises/math/sets/intervals/intervalsIntersection.d.ts.map +1 -1
- package/lib/exercises/math/sets/intervals/intervalsIntersection.js +101 -31
- package/lib/exercises/math/sets/intervals/intervalsUnion.d.ts +3 -7
- package/lib/exercises/math/sets/intervals/intervalsUnion.d.ts.map +1 -1
- package/lib/exercises/math/sets/intervals/intervalsUnion.js +68 -19
- package/lib/exercises/pc/index.d.ts +4 -0
- package/lib/exercises/pc/index.d.ts.map +1 -1
- package/lib/exercises/pc/index.js +4 -6
- package/lib/exercises/vea/equationVEA.js +2 -2
- package/lib/geogebra/lagrange.d.ts.map +1 -1
- package/lib/geogebra/spline.d.ts.map +1 -1
- package/lib/index.d.ts +38 -20
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/inequations/inequation.d.ts +1 -1
- package/lib/math/inequations/inequation.d.ts.map +1 -1
- package/lib/math/numbers/integer/integer.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.d.ts +2 -3
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/polynomials/trinom.d.ts +2 -4
- package/lib/math/polynomials/trinom.d.ts.map +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +4 -4
- package/lib/tree/nodes/equations/equationSolutionNode.d.ts +0 -1
- package/lib/tree/nodes/equations/equationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equationSolutionNode.js +0 -3
- package/lib/tree/nodes/inequations/inequationNode.d.ts +2 -1
- package/lib/tree/nodes/inequations/inequationNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationNode.js +4 -3
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +0 -1
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationSolutionNode.js +0 -3
- package/lib/tree/nodes/numbers/numberNode.d.ts +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +6 -1
- package/lib/tree/nodes/sets/closure.d.ts +5 -0
- package/lib/tree/nodes/sets/closure.d.ts.map +1 -1
- package/lib/tree/nodes/sets/closure.js +32 -0
- package/lib/tree/nodes/sets/discreteSetNode.d.ts +4 -4
- package/lib/tree/nodes/sets/discreteSetNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/discreteSetNode.js +3 -4
- package/lib/tree/nodes/sets/intervalNode.d.ts +13 -1
- package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/intervalNode.js +154 -3
- package/lib/tree/parsers/discreteSetParser.d.ts +2 -2
- package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
- package/lib/tree/parsers/discreteSetParser.js +2 -1
- package/lib/tree/parsers/equationSolutionParser.js +1 -1
- package/lib/tree/parsers/powerParser.d.ts +1 -1
- package/lib/tree/parsers/rationalParser.d.ts +1 -1
- package/lib/tree/parsers/unionIntervalParser.d.ts.map +1 -1
- package/lib/tree/parsers/unionIntervalParser.js +3 -1
- package/package.json +1 -1
|
@@ -83,6 +83,18 @@ class Closure {
|
|
|
83
83
|
else
|
|
84
84
|
return ClosureType.OF;
|
|
85
85
|
}
|
|
86
|
+
static toBrackets(closure) {
|
|
87
|
+
switch (closure) {
|
|
88
|
+
case ClosureType.FF:
|
|
89
|
+
return ["[", "]"];
|
|
90
|
+
case ClosureType.FO:
|
|
91
|
+
return ["[", "["];
|
|
92
|
+
case ClosureType.OF:
|
|
93
|
+
return ["]", "]"];
|
|
94
|
+
case ClosureType.OO:
|
|
95
|
+
return ["]", "["];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
86
98
|
static isLeftOpen(closure) {
|
|
87
99
|
switch (closure) {
|
|
88
100
|
case ClosureType.FF:
|
|
@@ -105,3 +117,23 @@ class Closure {
|
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
exports.Closure = Closure;
|
|
120
|
+
Closure.getLessLeftStrict = (a, b) => {
|
|
121
|
+
if (a === "[" || b === "[")
|
|
122
|
+
return "[";
|
|
123
|
+
return "]";
|
|
124
|
+
};
|
|
125
|
+
Closure.getLessRightStrict = (a, b) => {
|
|
126
|
+
if (a === "]" || b === "]")
|
|
127
|
+
return "]";
|
|
128
|
+
return "[";
|
|
129
|
+
};
|
|
130
|
+
Closure.getMostLeftStrict = (a, b) => {
|
|
131
|
+
if (a === "]" || b === "]")
|
|
132
|
+
return "]";
|
|
133
|
+
return "[";
|
|
134
|
+
};
|
|
135
|
+
Closure.getMostRightStrict = (a, b) => {
|
|
136
|
+
if (a === "[" || b === "[")
|
|
137
|
+
return "[";
|
|
138
|
+
return "]";
|
|
139
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../algebraicNode";
|
|
1
2
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node";
|
|
2
3
|
import { SetIds, SetNode } from "./setNode";
|
|
3
4
|
export declare function isDiscreteSetNode(a: Node): a is DiscreteSetNode;
|
|
@@ -5,9 +6,9 @@ export declare class DiscreteSetNode implements SetNode {
|
|
|
5
6
|
type: NodeType;
|
|
6
7
|
id: SetIds;
|
|
7
8
|
opts?: NodeOptions | undefined;
|
|
8
|
-
elements:
|
|
9
|
+
elements: AlgebraicNode[];
|
|
9
10
|
isEmpty: boolean;
|
|
10
|
-
constructor(elements:
|
|
11
|
+
constructor(elements: AlgebraicNode[], opts?: NodeOptions);
|
|
11
12
|
isEmptySet(): boolean;
|
|
12
13
|
toAllValidTexs(): string[];
|
|
13
14
|
toIdentifiers(): {
|
|
@@ -18,10 +19,9 @@ export declare class DiscreteSetNode implements SetNode {
|
|
|
18
19
|
};
|
|
19
20
|
toEquivalentNodes(opts?: NodeOptions): DiscreteSetNode[];
|
|
20
21
|
toMathString(): string;
|
|
21
|
-
toMathjs(): string;
|
|
22
22
|
toTex(): string;
|
|
23
23
|
toDeleteRandomElement(): DiscreteSetNode;
|
|
24
|
-
simplify():
|
|
24
|
+
simplify(): DiscreteSetNode;
|
|
25
25
|
}
|
|
26
26
|
export declare const EmptySet: DiscreteSetNode;
|
|
27
27
|
//# sourceMappingURL=discreteSetNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discreteSetNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/sets/discreteSetNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAa,MAAM,WAAW,CAAC;AACvD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,eAAe,CAE/D;AACD,qBAAa,eAAgB,YAAW,OAAO;IAC7C,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"discreteSetNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/sets/discreteSetNode.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,EAAE,MAAM,EAAE,OAAO,EAAa,MAAM,WAAW,CAAC;AACvD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,eAAe,CAE/D;AACD,qBAAa,eAAgB,YAAW,OAAO;IAC7C,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;gBACL,QAAQ,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,EAAE,WAAW;IAOzD,UAAU;IAGV,cAAc;IAGd,aAAa;;;;;;IAMb,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAyBpC,YAAY;IAIZ,KAAK;IAOL,qBAAqB;IAMrB,QAAQ;CAOT;AAED,eAAO,MAAM,QAAQ,iBAA0B,CAAC"}
|
|
@@ -55,9 +55,6 @@ class DiscreteSetNode {
|
|
|
55
55
|
toMathString() {
|
|
56
56
|
return `{${this.elements.map((el) => el.toTex()).join(";")}}`;
|
|
57
57
|
}
|
|
58
|
-
toMathjs() {
|
|
59
|
-
return `{${this.elements.map((el) => el.toTex()).join(";")}}`;
|
|
60
|
-
}
|
|
61
58
|
toTex() {
|
|
62
59
|
if (!this.elements.length)
|
|
63
60
|
return `\\varnothing`;
|
|
@@ -72,7 +69,9 @@ class DiscreteSetNode {
|
|
|
72
69
|
return new DiscreteSetNode(newElements);
|
|
73
70
|
}
|
|
74
71
|
simplify() {
|
|
75
|
-
return this
|
|
72
|
+
return new DiscreteSetNode(this.elements
|
|
73
|
+
.map((el) => el.simplify())
|
|
74
|
+
.sort((a, b) => a.evaluate() - b.evaluate()));
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
exports.DiscreteSetNode = DiscreteSetNode;
|
|
@@ -3,9 +3,15 @@ import { InequationNode } from "../inequations/inequationNode";
|
|
|
3
3
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node";
|
|
4
4
|
import { NodeIdentifiers } from "../nodeConstructor";
|
|
5
5
|
import { ClosureType } from "./closure";
|
|
6
|
+
import { DiscreteSetNode } from "./discreteSetNode";
|
|
6
7
|
import { SetIds, SetNode } from "./setNode";
|
|
7
8
|
import { UnionIntervalNode } from "./unionIntervalNode";
|
|
8
9
|
export declare function isIntervalNode(a: Node): a is IntervalNode;
|
|
10
|
+
export declare abstract class IntervalNodeConstructor {
|
|
11
|
+
static random(): IntervalNode;
|
|
12
|
+
static differentRandoms(nb: number): IntervalNode[];
|
|
13
|
+
static fromIdentifiers(ids: IntervalNodeIdentifiers): IntervalNode;
|
|
14
|
+
}
|
|
9
15
|
export type IntervalNodeIdentifiers = {
|
|
10
16
|
id: NodeIds;
|
|
11
17
|
leftChild: NodeIdentifiers;
|
|
@@ -26,7 +32,7 @@ export declare class IntervalNode implements SetNode {
|
|
|
26
32
|
toEquivalentNodes(opts?: NodeOptions): IntervalNode[];
|
|
27
33
|
toInequality(middleChild?: AlgebraicNode): InequationNode;
|
|
28
34
|
toMathString(): string;
|
|
29
|
-
|
|
35
|
+
equals(i: IntervalNode): boolean;
|
|
30
36
|
toReversedClosure(): IntervalNode;
|
|
31
37
|
toLeftReversedClosure(): IntervalNode;
|
|
32
38
|
toRightReversedClosure(): IntervalNode;
|
|
@@ -37,5 +43,11 @@ export declare class IntervalNode implements SetNode {
|
|
|
37
43
|
toIdentifiers(): IntervalNodeIdentifiers;
|
|
38
44
|
toText(isPlural: boolean, isFeminine: boolean): string;
|
|
39
45
|
simplify(opts?: SimplifyOptions): IntervalNode;
|
|
46
|
+
isLeftClosed(): boolean;
|
|
47
|
+
isRightClosed(): boolean;
|
|
48
|
+
includes(a: AlgebraicNode): boolean;
|
|
49
|
+
isDisjoint(otherInt: IntervalNode): void;
|
|
50
|
+
intersection(otherInt: IntervalNode): DiscreteSetNode | IntervalNode;
|
|
51
|
+
union(otherInt: IntervalNode): IntervalNode | UnionIntervalNode;
|
|
40
52
|
}
|
|
41
53
|
//# sourceMappingURL=intervalNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/sets/intervalNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intervalNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/sets/intervalNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAkB,MAAM,oBAAoB,CAAC;AAIrE,OAAO,EAAW,WAAW,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,eAAe,EAAY,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAa,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,8BAAsB,uBAAuB;IAC3C,MAAM,CAAC,MAAM;IA2Cb,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAYlC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,uBAAuB;CAQpD;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AACF,qBAAa,YAAa,YAAW,OAAO;IAC1C,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,WAAW,CAAC;IACrB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;gBAEf,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa,EAChB,OAAO,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,WAAW;IAWpB,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW;IAMjC,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAoBpC,YAAY,CAAC,WAAW,CAAC,EAAE,aAAa;IA4BxC,YAAY;IAIZ,MAAM,CAAC,CAAC,EAAE,YAAY;IAMtB,iBAAiB;IAGjB,qBAAqB;IAGrB,sBAAsB;IAGtB,wBAAwB;IAYxB,YAAY;IAkCZ,KAAK;IAWL,SAAS,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAOvC,aAAa,IAAI,uBAAuB;IAUxC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO;IAiB7C,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAS/B,YAAY;IAGZ,aAAa;IAGb,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO;IAanC,UAAU,CAAC,QAAQ,EAAE,YAAY;IAEjC,YAAY,CAAC,QAAQ,EAAE,YAAY;IAwDnC,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,GAAG,iBAAiB;CAkDhE"}
|
|
@@ -1,20 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntervalNode = exports.isIntervalNode = void 0;
|
|
3
|
+
exports.IntervalNode = exports.IntervalNodeConstructor = exports.isIntervalNode = void 0;
|
|
4
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
5
|
+
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
4
6
|
const random_1 = require("../../../utils/alea/random");
|
|
5
7
|
const cartesianProducts_1 = require("../../../utils/arrays/cartesianProducts");
|
|
6
8
|
const inequationNode_1 = require("../inequations/inequationNode");
|
|
7
9
|
const node_1 = require("../node");
|
|
10
|
+
const nodeConstructor_1 = require("../nodeConstructor");
|
|
8
11
|
const constantNode_1 = require("../numbers/constantNode");
|
|
9
12
|
const infiniteNode_1 = require("../numbers/infiniteNode");
|
|
10
13
|
const variableNode_1 = require("../variables/variableNode");
|
|
11
14
|
const closure_1 = require("./closure");
|
|
15
|
+
const discreteSetNode_1 = require("./discreteSetNode");
|
|
12
16
|
const setNode_1 = require("./setNode");
|
|
13
17
|
const unionIntervalNode_1 = require("./unionIntervalNode");
|
|
14
18
|
function isIntervalNode(a) {
|
|
15
19
|
return (0, setNode_1.isSetNode)(a) && a.id === setNode_1.SetIds.interval;
|
|
16
20
|
}
|
|
17
21
|
exports.isIntervalNode = isIntervalNode;
|
|
22
|
+
class IntervalNodeConstructor {
|
|
23
|
+
static random() {
|
|
24
|
+
const randType = (0, randint_1.randint)(0, 6);
|
|
25
|
+
let a, b;
|
|
26
|
+
let min, max, closure;
|
|
27
|
+
switch (randType) {
|
|
28
|
+
case 0:
|
|
29
|
+
min = infiniteNode_1.MinusInfinityNode;
|
|
30
|
+
max = (0, randint_1.randint)(-10, 10).toTree();
|
|
31
|
+
closure = (0, coinFlip_1.coinFlip)() ? closure_1.ClosureType.OF : closure_1.ClosureType.OO;
|
|
32
|
+
break;
|
|
33
|
+
case 1:
|
|
34
|
+
min = (0, randint_1.randint)(-10, 10).toTree();
|
|
35
|
+
max = infiniteNode_1.PlusInfinityNode;
|
|
36
|
+
closure = (0, coinFlip_1.coinFlip)() ? closure_1.ClosureType.OO : closure_1.ClosureType.FO;
|
|
37
|
+
break;
|
|
38
|
+
case 2:
|
|
39
|
+
a = (0, randint_1.randint)(-10, 10);
|
|
40
|
+
min = a.toTree();
|
|
41
|
+
max = (0, randint_1.randint)(a + 1, a + 10).toTree();
|
|
42
|
+
closure = closure_1.ClosureType.FF;
|
|
43
|
+
break;
|
|
44
|
+
case 3:
|
|
45
|
+
a = (0, randint_1.randint)(-10, 10);
|
|
46
|
+
min = a.toTree();
|
|
47
|
+
max = (0, randint_1.randint)(a + 1, a + 10).toTree();
|
|
48
|
+
closure = closure_1.ClosureType.OF;
|
|
49
|
+
break;
|
|
50
|
+
case 4:
|
|
51
|
+
a = (0, randint_1.randint)(-10, 10);
|
|
52
|
+
min = a.toTree();
|
|
53
|
+
max = (0, randint_1.randint)(a + 1, a + 10).toTree();
|
|
54
|
+
closure = closure_1.ClosureType.FO;
|
|
55
|
+
break;
|
|
56
|
+
case 5:
|
|
57
|
+
default:
|
|
58
|
+
a = (0, randint_1.randint)(-10, 10);
|
|
59
|
+
min = a.toTree();
|
|
60
|
+
max = (0, randint_1.randint)(a + 1, a + 10).toTree();
|
|
61
|
+
closure = closure_1.ClosureType.OO;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return new IntervalNode(min, max, closure);
|
|
65
|
+
}
|
|
66
|
+
static differentRandoms(nb) {
|
|
67
|
+
const res = [];
|
|
68
|
+
for (let i = 0; i < nb; i++) {
|
|
69
|
+
let interval;
|
|
70
|
+
do {
|
|
71
|
+
interval = this.random();
|
|
72
|
+
} while (res.some((int) => int.equals(interval)));
|
|
73
|
+
res.push(this.random());
|
|
74
|
+
}
|
|
75
|
+
return res;
|
|
76
|
+
}
|
|
77
|
+
static fromIdentifiers(ids) {
|
|
78
|
+
return new IntervalNode((0, nodeConstructor_1.reifyAlgebraic)(ids.leftChild), (0, nodeConstructor_1.reifyAlgebraic)(ids.rightChild), ids.closure, ids.opts);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.IntervalNodeConstructor = IntervalNodeConstructor;
|
|
18
82
|
class IntervalNode {
|
|
19
83
|
constructor(a, b, closure, opts) {
|
|
20
84
|
this.type = node_1.NodeType.set;
|
|
@@ -59,8 +123,8 @@ class IntervalNode {
|
|
|
59
123
|
toMathString() {
|
|
60
124
|
return this.toTex();
|
|
61
125
|
}
|
|
62
|
-
|
|
63
|
-
return this.
|
|
126
|
+
equals(i) {
|
|
127
|
+
return (i.a.equals(this.a) && i.b.equals(this.b) && i.closure === this.closure);
|
|
64
128
|
}
|
|
65
129
|
toReversedClosure() {
|
|
66
130
|
return new IntervalNode(this.a, this.b, closure_1.Closure.reverse(this.closure));
|
|
@@ -140,5 +204,92 @@ class IntervalNode {
|
|
|
140
204
|
simplify(opts) {
|
|
141
205
|
return new IntervalNode(this.a.simplify(opts), this.b.simplify(opts), this.closure, this.opts);
|
|
142
206
|
}
|
|
207
|
+
isLeftClosed() {
|
|
208
|
+
return this.closure === closure_1.ClosureType.FF || this.closure === closure_1.ClosureType.FO;
|
|
209
|
+
}
|
|
210
|
+
isRightClosed() {
|
|
211
|
+
return this.closure === closure_1.ClosureType.FF || this.closure === closure_1.ClosureType.OF;
|
|
212
|
+
}
|
|
213
|
+
includes(a) {
|
|
214
|
+
const ev = a.evaluate();
|
|
215
|
+
const aEv = this.a.evaluate();
|
|
216
|
+
const bEv = this.b.evaluate();
|
|
217
|
+
if (ev === Number.NEGATIVE_INFINITY)
|
|
218
|
+
return aEv === Number.NEGATIVE_INFINITY;
|
|
219
|
+
if (ev === Number.POSITIVE_INFINITY)
|
|
220
|
+
return bEv === Number.POSITIVE_INFINITY;
|
|
221
|
+
if (Math.abs(ev - aEv) < 0.0000000001)
|
|
222
|
+
return this.isLeftClosed();
|
|
223
|
+
if (Math.abs(ev - bEv) < 0.0000000001)
|
|
224
|
+
return this.isRightClosed();
|
|
225
|
+
return ev > aEv && ev < bEv;
|
|
226
|
+
}
|
|
227
|
+
isDisjoint(otherInt) { }
|
|
228
|
+
intersection(otherInt) {
|
|
229
|
+
const [thisA, thisB] = [this.a.evaluate(), this.b.evaluate()];
|
|
230
|
+
const [otherA, otherB] = [otherInt.a.evaluate(), otherInt.b.evaluate()];
|
|
231
|
+
const ordered = thisA < otherA ? [this, otherInt] : [otherInt, this];
|
|
232
|
+
const orderedEv = ordered.map((e) => {
|
|
233
|
+
return [e.a.evaluate(), e.b.evaluate()];
|
|
234
|
+
});
|
|
235
|
+
const orderedBrackets = ordered.map((int) => closure_1.Closure.toBrackets(int.closure));
|
|
236
|
+
if (ordered[0].includes(ordered[1].a) ||
|
|
237
|
+
Math.abs(thisA - otherA) < 0.0000000001) {
|
|
238
|
+
if (Math.abs(orderedEv[0][1] - orderedEv[1][0]) < 0.0000000001) {
|
|
239
|
+
return new discreteSetNode_1.DiscreteSetNode([ordered[1].a]);
|
|
240
|
+
}
|
|
241
|
+
let leftBracket = "[";
|
|
242
|
+
if (Math.abs(thisA - otherA) < 0.0000000001) {
|
|
243
|
+
leftBracket = closure_1.Closure.getMostLeftStrict(orderedBrackets[0][0], orderedBrackets[1][0]);
|
|
244
|
+
}
|
|
245
|
+
else
|
|
246
|
+
leftBracket = orderedBrackets[1][0];
|
|
247
|
+
let rightBracket = "[";
|
|
248
|
+
if (Math.abs(thisB - otherB) < 0.0000000001) {
|
|
249
|
+
rightBracket = closure_1.Closure.getMostRightStrict(orderedBrackets[0][1], orderedBrackets[1][1]);
|
|
250
|
+
return new IntervalNode(ordered[1].a, ordered[1].b, closure_1.Closure.fromBrackets(leftBracket, rightBracket));
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const rightBornIndex = ordered[0].b.evaluate() < ordered[1].b.evaluate() ? 0 : 1;
|
|
254
|
+
const right = ordered[rightBornIndex].b;
|
|
255
|
+
rightBracket = orderedBrackets[rightBornIndex][1];
|
|
256
|
+
return new IntervalNode(ordered[1].a, right, closure_1.Closure.fromBrackets(leftBracket, rightBracket));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
return discreteSetNode_1.EmptySet;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
union(otherInt) {
|
|
264
|
+
const [thisA, thisB] = [this.a.evaluate(), this.b.evaluate()];
|
|
265
|
+
const [otherA, otherB] = [otherInt.a.evaluate(), otherInt.b.evaluate()];
|
|
266
|
+
const ordered = thisA < otherA ? [this, otherInt] : [otherInt, this];
|
|
267
|
+
const orderedBrackets = ordered.map((int) => closure_1.Closure.toBrackets(int.closure));
|
|
268
|
+
if (ordered[0].includes(ordered[1].a) ||
|
|
269
|
+
ordered[1].includes(ordered[0].b) ||
|
|
270
|
+
ordered[1].includes(ordered[0].a) ||
|
|
271
|
+
Math.abs(thisA - otherA) < 0.0000000001) {
|
|
272
|
+
let leftBracket = "[";
|
|
273
|
+
if (Math.abs(thisA - otherA) < 0.0000000001) {
|
|
274
|
+
leftBracket = closure_1.Closure.getLessLeftStrict(orderedBrackets[0][0], orderedBrackets[1][0]);
|
|
275
|
+
}
|
|
276
|
+
else
|
|
277
|
+
leftBracket = orderedBrackets[0][0];
|
|
278
|
+
let rightBracket = "[";
|
|
279
|
+
if (Math.abs(thisB - otherB) < 0.0000000001) {
|
|
280
|
+
rightBracket = closure_1.Closure.getLessRightStrict(orderedBrackets[0][1], orderedBrackets[1][1]);
|
|
281
|
+
return new IntervalNode(ordered[0].a, ordered[1].b, closure_1.Closure.fromBrackets(leftBracket, rightBracket));
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
const rightBornIndex = ordered[0].b.evaluate() > ordered[1].b.evaluate() ? 0 : 1;
|
|
285
|
+
const right = ordered[rightBornIndex].b;
|
|
286
|
+
rightBracket = orderedBrackets[rightBornIndex][1];
|
|
287
|
+
return new IntervalNode(ordered[0].a, right, closure_1.Closure.fromBrackets(leftBracket, rightBracket));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
return new unionIntervalNode_1.UnionIntervalNode([ordered[0], ordered[1]], this.opts);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
143
294
|
}
|
|
144
295
|
exports.IntervalNode = IntervalNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const discreteSetParser: (str: string) => false |
|
|
1
|
+
import { DiscreteSetNode } from "../nodes/sets/discreteSetNode";
|
|
2
|
+
export declare const discreteSetParser: (str: string) => false | DiscreteSetNode;
|
|
3
3
|
//# sourceMappingURL=discreteSetParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discreteSetParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/discreteSetParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discreteSetParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/discreteSetParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIhE,eAAO,MAAM,iBAAiB,QAAS,MAAM,4BAe5C,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.discreteSetParser = void 0;
|
|
4
|
+
const discreteSetNode_1 = require("../nodes/sets/discreteSetNode");
|
|
4
5
|
const latexParser_1 = require("./latexParser");
|
|
5
6
|
const discreteSetParser = (str) => {
|
|
6
7
|
try {
|
|
@@ -14,7 +15,7 @@ const discreteSetParser = (str) => {
|
|
|
14
15
|
const elements = formated.split(";").map((e) => (0, latexParser_1.parseAlgebraic)(e));
|
|
15
16
|
if (elements.some((e) => !e))
|
|
16
17
|
return false;
|
|
17
|
-
return elements;
|
|
18
|
+
return new discreteSetNode_1.DiscreteSetNode(elements);
|
|
18
19
|
}
|
|
19
20
|
catch (err) {
|
|
20
21
|
return false;
|
|
@@ -17,7 +17,7 @@ const equationSolutionParser = (str, variable = "x") => {
|
|
|
17
17
|
: undefined;
|
|
18
18
|
if (varNode === undefined)
|
|
19
19
|
return false;
|
|
20
|
-
if (children[varNode].name !==
|
|
20
|
+
if (children[varNode].name !== variable)
|
|
21
21
|
return false;
|
|
22
22
|
const scalar = children[(varNode + 1) % 2];
|
|
23
23
|
if (!(0, algebraicNode_1.isAlgebraicNode)(scalar) || !scalar.isNumeric)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const powerParser: (ans: string) => false | import("../nodes/
|
|
1
|
+
export declare const powerParser: (ans: string) => false | import("../nodes/functions/sqrtNode").SqrtNode | import("../nodes/operators/powerNode").PowerNode | import("../nodes/operators/fractionNode").FractionNode;
|
|
2
2
|
//# sourceMappingURL=powerParser.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FractionNode } from "../nodes/operators/fractionNode";
|
|
2
|
-
export declare const rationalParser: (ans: string) => false | import("../nodes/numbers/constantNode").ConstantNode | import("../nodes/numbers/numberNode").NumberNode |
|
|
2
|
+
export declare const rationalParser: (ans: string) => false | import("../nodes/numbers/constantNode").ConstantNode | import("../nodes/numbers/numberNode").NumberNode | import("../nodes/functions/oppositeNode").OppositeNode<import("../nodes/algebraicNode").AlgebraicNode> | FractionNode;
|
|
3
3
|
//# sourceMappingURL=rationalParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unionIntervalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/unionIntervalParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,KAAK,IAAI,GAAG;IACV,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,mBAAmB,QAAS,MAAM,SAAS,IAAI,
|
|
1
|
+
{"version":3,"file":"unionIntervalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/unionIntervalParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,KAAK,IAAI,GAAG;IACV,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,mBAAmB,QAAS,MAAM,SAAS,IAAI,6CAmB3D,CAAC"}
|
|
@@ -17,7 +17,9 @@ const unionIntervalParser = (ans, opts) => {
|
|
|
17
17
|
return false;
|
|
18
18
|
if (intervals.length === 1)
|
|
19
19
|
return intervals[0];
|
|
20
|
-
return new unionIntervalNode_1.UnionIntervalNode(intervals)
|
|
20
|
+
return new unionIntervalNode_1.UnionIntervalNode(intervals.sort((a, b) => {
|
|
21
|
+
return a.a.evaluate() - b.a.evaluate();
|
|
22
|
+
}));
|
|
21
23
|
}
|
|
22
24
|
catch (err) {
|
|
23
25
|
return false;
|