math-exercises 1.2.8 → 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/{src → lib}/exercises/calcul/rounding/rounding.js +86 -87
- 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 -36
- 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/rounding.ts +0 -87
- 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/exercise.ts +0 -22
- package/src/exercises/exercises.js +0 -85
- package/src/exercises/exercises.ts +0 -94
- 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 -5
- package/src/index.ts +0 -13
- 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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscreteSet = void 0;
|
|
4
|
+
const random_1 = require("../utils/random");
|
|
5
|
+
class DiscreteSet {
|
|
6
|
+
constructor(elements) {
|
|
7
|
+
this.elements = Array.from(new Set(elements));
|
|
8
|
+
let tex = "\\{";
|
|
9
|
+
this.elements.forEach((el, index) => {
|
|
10
|
+
tex += el.tex;
|
|
11
|
+
if (index < this.elements.length - 1)
|
|
12
|
+
tex += ";";
|
|
13
|
+
else
|
|
14
|
+
tex += "\\}";
|
|
15
|
+
});
|
|
16
|
+
this.tex = tex;
|
|
17
|
+
}
|
|
18
|
+
toTex() {
|
|
19
|
+
return this.tex;
|
|
20
|
+
}
|
|
21
|
+
includes(el) {
|
|
22
|
+
return this.elements.some((nb) => nb.value === el.value && nb.tex === el.tex);
|
|
23
|
+
}
|
|
24
|
+
getRandomElement() {
|
|
25
|
+
return (0, random_1.random)(this.elements);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DiscreteSet = DiscreteSet;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// export abstract class EmptySet implements MathSetInterface {
|
|
4
|
-
// tex: string = "\\emptyset";
|
|
5
|
-
// getRandomElement = () => null;
|
|
6
|
-
// }
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { MathSetInterface } from "./mathSetInterface";
|
|
3
|
+
// export abstract class EmptySet implements MathSetInterface {
|
|
4
|
+
// tex: string = "\\emptyset";
|
|
5
|
+
// getRandomElement = () => null;
|
|
6
|
+
// }
|
|
@@ -1,113 +1,108 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
exports.Interval = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var BoundType;
|
|
11
|
-
(function (BoundType) {
|
|
12
|
-
BoundType["OO"] = "]a;b[";
|
|
13
|
-
BoundType["OF"] = "]a;b]";
|
|
14
|
-
BoundType["FO"] = "[a;b[";
|
|
15
|
-
BoundType["FF"] = "[a;b]";
|
|
16
|
-
})(BoundType || (BoundType = {}));
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* [[a; b]] pour un interval d'integer; [a;b] pour des réels
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//si
|
|
60
|
-
//si
|
|
61
|
-
//si
|
|
62
|
-
//si
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
return Interval;
|
|
112
|
-
}());
|
|
113
|
-
exports.Interval = Interval;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Interval = void 0;
|
|
4
|
+
const epsilon_1 = require("../../numbers/epsilon");
|
|
5
|
+
const nombre_1 = require("../../numbers/nombre");
|
|
6
|
+
const round_1 = require("../../mathutils/round");
|
|
7
|
+
const mathSet_1 = require("../mathSet");
|
|
8
|
+
const integer_1 = require("../../numbers/integer/integer");
|
|
9
|
+
const real_1 = require("../../numbers/reals/real");
|
|
10
|
+
var BoundType;
|
|
11
|
+
(function (BoundType) {
|
|
12
|
+
BoundType["OO"] = "]a;b[";
|
|
13
|
+
BoundType["OF"] = "]a;b]";
|
|
14
|
+
BoundType["FO"] = "[a;b[";
|
|
15
|
+
BoundType["FF"] = "[a;b]";
|
|
16
|
+
})(BoundType || (BoundType = {}));
|
|
17
|
+
class Interval {
|
|
18
|
+
/**
|
|
19
|
+
* [[a; b]] pour un interval d'integer; [a;b] pour des réels
|
|
20
|
+
*/
|
|
21
|
+
constructor(tex = "[-10; 10]") {
|
|
22
|
+
this.tex = tex;
|
|
23
|
+
const isInt = tex[1] === "[" || tex[1] === "]";
|
|
24
|
+
this.type = isInt ? nombre_1.NumberType.Integer : nombre_1.NumberType.Real;
|
|
25
|
+
const left = tex[0];
|
|
26
|
+
const right = tex[tex.length - 1];
|
|
27
|
+
const [a, b] = tex
|
|
28
|
+
.slice(isInt ? 2 : 1, isInt ? tex.length - 2 : tex.length - 1)
|
|
29
|
+
.split(";");
|
|
30
|
+
switch (`${left}a;b${right}`) {
|
|
31
|
+
case "[a;b]":
|
|
32
|
+
this.boundType = BoundType.FF;
|
|
33
|
+
break;
|
|
34
|
+
case "]a;b[":
|
|
35
|
+
this.boundType = BoundType.OO;
|
|
36
|
+
break;
|
|
37
|
+
case "[a;b[":
|
|
38
|
+
this.boundType = BoundType.FO;
|
|
39
|
+
break;
|
|
40
|
+
case "]a;b]":
|
|
41
|
+
this.boundType = BoundType.OF;
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw console.error("wrong interval");
|
|
45
|
+
}
|
|
46
|
+
function getBound(bound) {
|
|
47
|
+
return bound === "-\\infty"
|
|
48
|
+
? Number.NEGATIVE_INFINITY
|
|
49
|
+
: bound === "+\\infty"
|
|
50
|
+
? Number.POSITIVE_INFINITY
|
|
51
|
+
: Number(bound);
|
|
52
|
+
}
|
|
53
|
+
this.min = getBound(a);
|
|
54
|
+
this.max = getBound(b);
|
|
55
|
+
}
|
|
56
|
+
// union(interval: Interval): MathSet {
|
|
57
|
+
//[a,b] [c,d]
|
|
58
|
+
//si a=c return a, max(b,d)
|
|
59
|
+
//si si b = d return min(a,c), b
|
|
60
|
+
//si a=d return c,b sauf si OXXO
|
|
61
|
+
//si b=c return a,d sauf si XOOX
|
|
62
|
+
//si c > b ou d < a alors union disjointe avec plus petit en 1er
|
|
63
|
+
//sinon return min(a,c), max(b,d)
|
|
64
|
+
//res = a
|
|
65
|
+
// return new MathSet();
|
|
66
|
+
// }
|
|
67
|
+
exclude(nb) {
|
|
68
|
+
const rand = () => {
|
|
69
|
+
let x;
|
|
70
|
+
do {
|
|
71
|
+
x = this.getRandomElement();
|
|
72
|
+
} while (x.value === nb);
|
|
73
|
+
return x;
|
|
74
|
+
};
|
|
75
|
+
return new mathSet_1.MathSet(this.toTex() + `\\{${nb}\\}`, rand);
|
|
76
|
+
}
|
|
77
|
+
difference(set) {
|
|
78
|
+
const rand = () => {
|
|
79
|
+
let x;
|
|
80
|
+
do {
|
|
81
|
+
x = this.getRandomElement();
|
|
82
|
+
} while (set.includes(x));
|
|
83
|
+
return x;
|
|
84
|
+
};
|
|
85
|
+
return new mathSet_1.MathSet(this.toTex() + `\\ ${set.toTex()}`, rand);
|
|
86
|
+
}
|
|
87
|
+
toTex() {
|
|
88
|
+
return this.tex;
|
|
89
|
+
}
|
|
90
|
+
getRandomElement(precision = this.type === nombre_1.NumberType.Integer ? 0 : 2) {
|
|
91
|
+
if (this.min === -Infinity || this.max === Infinity)
|
|
92
|
+
throw Error("Can't chose amongst infinity");
|
|
93
|
+
let min = this.boundType === BoundType.OO || this.boundType === BoundType.OF
|
|
94
|
+
? this.min + epsilon_1.EPSILON
|
|
95
|
+
: this.min;
|
|
96
|
+
let max = this.boundType === BoundType.OO || this.boundType === BoundType.FO
|
|
97
|
+
? this.max - epsilon_1.EPSILON
|
|
98
|
+
: this.max;
|
|
99
|
+
const value = (0, round_1.round)(min + Math.random() * (max - this.min), precision);
|
|
100
|
+
switch (this.type) {
|
|
101
|
+
case nombre_1.NumberType.Integer:
|
|
102
|
+
return new integer_1.Integer(value);
|
|
103
|
+
default:
|
|
104
|
+
return new real_1.Real(value, value.toString());
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Interval = Interval;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MathSet = void 0;
|
|
4
|
+
class MathSet {
|
|
5
|
+
constructor(tex, getRandomElement) {
|
|
6
|
+
this.tex = tex;
|
|
7
|
+
this.getRandomElement = getRandomElement;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MathSet = MathSet;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
exports.FunctionNode = exports.FunctionsIds = void 0;
|
|
4
|
-
|
|
5
|
-
var FunctionsIds;
|
|
6
|
-
(function (FunctionsIds) {
|
|
7
|
-
FunctionsIds[FunctionsIds["opposite"] = 0] = "opposite";
|
|
8
|
-
FunctionsIds[FunctionsIds["sqrt"] = 1] = "sqrt";
|
|
9
|
-
})(FunctionsIds = exports.FunctionsIds || (exports.FunctionsIds = {}));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.type = node_1.NodeType
|
|
13
|
-
this.id = id;
|
|
14
|
-
this.child = child;
|
|
15
|
-
this.tex = tex;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.FunctionNode = FunctionNode;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionNode = exports.FunctionsIds = void 0;
|
|
4
|
+
const node_1 = require("../node");
|
|
5
|
+
var FunctionsIds;
|
|
6
|
+
(function (FunctionsIds) {
|
|
7
|
+
FunctionsIds[FunctionsIds["opposite"] = 0] = "opposite";
|
|
8
|
+
FunctionsIds[FunctionsIds["sqrt"] = 1] = "sqrt";
|
|
9
|
+
})(FunctionsIds = exports.FunctionsIds || (exports.FunctionsIds = {}));
|
|
10
|
+
class FunctionNode {
|
|
11
|
+
constructor(id, child, tex) {
|
|
12
|
+
this.type = node_1.NodeType.function;
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.child = child;
|
|
15
|
+
this.tex = tex;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.FunctionNode = FunctionNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OppositeNode = void 0;
|
|
4
|
+
const functionNode_1 = require("./functionNode");
|
|
5
|
+
class OppositeNode extends functionNode_1.FunctionNode {
|
|
6
|
+
constructor(child) {
|
|
7
|
+
super(functionNode_1.FunctionsIds.opposite, child, "-");
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return `-(${this.child})`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.OppositeNode = OppositeNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SqrtNode = void 0;
|
|
4
|
+
const node_1 = require("../node");
|
|
5
|
+
const functionNode_1 = require("./functionNode");
|
|
6
|
+
class SqrtNode extends functionNode_1.FunctionNode {
|
|
7
|
+
constructor(child) {
|
|
8
|
+
super(functionNode_1.FunctionsIds.sqrt, child, "\\sqrt");
|
|
9
|
+
this.type = node_1.NodeType.function;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `sqrt(${this.child})`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.SqrtNode = SqrtNode;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
exports.NodeType = void 0;
|
|
4
|
-
var NodeType;
|
|
5
|
-
(function (NodeType) {
|
|
6
|
-
NodeType[NodeType["number"] = 0] = "number";
|
|
7
|
-
NodeType[NodeType["variable"] = 1] = "variable";
|
|
8
|
-
NodeType[NodeType["operator"] = 2] = "operator";
|
|
9
|
-
NodeType[NodeType["function"] = 3] = "function";
|
|
10
|
-
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeType = void 0;
|
|
4
|
+
var NodeType;
|
|
5
|
+
(function (NodeType) {
|
|
6
|
+
NodeType[NodeType["number"] = 0] = "number";
|
|
7
|
+
NodeType[NodeType["variable"] = 1] = "variable";
|
|
8
|
+
NodeType[NodeType["operator"] = 2] = "operator";
|
|
9
|
+
NodeType[NodeType["function"] = 3] = "function";
|
|
10
|
+
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberNode = void 0;
|
|
4
|
+
const node_1 = require("../node");
|
|
5
|
+
class NumberNode {
|
|
6
|
+
constructor(value, tex) {
|
|
7
|
+
this.type = node_1.NodeType.number;
|
|
8
|
+
this.value = value;
|
|
9
|
+
this.tex = tex || value + '';
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.tex}`;
|
|
13
|
+
}
|
|
14
|
+
toTex() {
|
|
15
|
+
return `${this.tex}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.NumberNode = NumberNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class AddNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
constructor(leftChild, rightChild) {
|
|
7
|
+
super(operatorNode_1.OperatorIds.add, leftChild, rightChild, true, "+");
|
|
8
|
+
this.leftChild = leftChild;
|
|
9
|
+
this.rightChild = rightChild;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.leftChild} + ${this.rightChild}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AddNode = AddNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DivideNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class DivideNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
/**
|
|
7
|
+
* @param leftChild num
|
|
8
|
+
* @param rightChild denum
|
|
9
|
+
*/
|
|
10
|
+
constructor(leftChild, rightChild) {
|
|
11
|
+
super(operatorNode_1.OperatorIds.divide, leftChild, rightChild, false, "\\div");
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return `(${this.leftChild}) \\div (${this.rightChild})`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.DivideNode = DivideNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EqualNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class EqualNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
constructor(leftChild, rightChild) {
|
|
7
|
+
super(operatorNode_1.OperatorIds.equal, leftChild, rightChild, true, "=");
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return `${this.leftChild} = ${this.rightChild}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.EqualNode = EqualNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FractionNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class FractionNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
/**
|
|
7
|
+
* @param leftChild num
|
|
8
|
+
* @param rightChild denum
|
|
9
|
+
*/
|
|
10
|
+
constructor(leftChild, rightChild) {
|
|
11
|
+
super(operatorNode_1.OperatorIds.fraction, leftChild, rightChild, false, "\\frac");
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return `\\frac{${this.leftChild}}{${this.rightChild}}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.FractionNode = FractionNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultiplyNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class MultiplyNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
constructor(leftChild, rightChild) {
|
|
7
|
+
super(operatorNode_1.OperatorIds.multiply, leftChild, rightChild, true, "\\times");
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return `(${this.leftChild})*(${this.rightChild})`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MultiplyNode = MultiplyNode;
|
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
exports.OperatorNode = exports.OperatorIds = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var OperatorIds;
|
|
7
|
-
(function (OperatorIds) {
|
|
8
|
-
OperatorIds[OperatorIds["add"] = 0] = "add";
|
|
9
|
-
OperatorIds[OperatorIds["substract"] = 1] = "substract";
|
|
10
|
-
OperatorIds[OperatorIds["multiply"] = 2] = "multiply";
|
|
11
|
-
OperatorIds[OperatorIds["fraction"] = 3] = "fraction";
|
|
12
|
-
OperatorIds[OperatorIds["divide"] = 4] = "divide";
|
|
13
|
-
OperatorIds[OperatorIds["power"] = 5] = "power";
|
|
14
|
-
OperatorIds[OperatorIds["equal"] = 6] = "equal";
|
|
15
|
-
})(OperatorIds = exports.OperatorIds || (exports.OperatorIds = {}));
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.type = node_1.NodeType.operator;
|
|
19
|
-
this.id = id;
|
|
20
|
-
this.leftChild = leftChild;
|
|
21
|
-
this.rightChild = rightChild;
|
|
22
|
-
this.isCommutative = isCommutative;
|
|
23
|
-
this.tex = tex;
|
|
24
|
-
}
|
|
25
|
-
/**shuffles in place */
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}());
|
|
37
|
-
exports.OperatorNode = OperatorNode;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperatorNode = exports.OperatorIds = void 0;
|
|
4
|
+
const coin_1 = require("../../../utils/coin");
|
|
5
|
+
const node_1 = require("../node");
|
|
6
|
+
var OperatorIds;
|
|
7
|
+
(function (OperatorIds) {
|
|
8
|
+
OperatorIds[OperatorIds["add"] = 0] = "add";
|
|
9
|
+
OperatorIds[OperatorIds["substract"] = 1] = "substract";
|
|
10
|
+
OperatorIds[OperatorIds["multiply"] = 2] = "multiply";
|
|
11
|
+
OperatorIds[OperatorIds["fraction"] = 3] = "fraction";
|
|
12
|
+
OperatorIds[OperatorIds["divide"] = 4] = "divide";
|
|
13
|
+
OperatorIds[OperatorIds["power"] = 5] = "power";
|
|
14
|
+
OperatorIds[OperatorIds["equal"] = 6] = "equal";
|
|
15
|
+
})(OperatorIds = exports.OperatorIds || (exports.OperatorIds = {}));
|
|
16
|
+
class OperatorNode {
|
|
17
|
+
constructor(id, leftChild, rightChild, isCommutative, tex) {
|
|
18
|
+
this.type = node_1.NodeType.operator;
|
|
19
|
+
this.id = id;
|
|
20
|
+
this.leftChild = leftChild;
|
|
21
|
+
this.rightChild = rightChild;
|
|
22
|
+
this.isCommutative = isCommutative;
|
|
23
|
+
this.tex = tex;
|
|
24
|
+
}
|
|
25
|
+
/**shuffles in place */
|
|
26
|
+
shuffle() {
|
|
27
|
+
if (!this.isCommutative)
|
|
28
|
+
return this;
|
|
29
|
+
if ((0, coin_1.coin)())
|
|
30
|
+
return this;
|
|
31
|
+
[this.leftChild, this.rightChild] = [this.rightChild, this.leftChild];
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.OperatorNode = OperatorNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PowerNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class PowerNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
constructor(leftChild, rightChild) {
|
|
7
|
+
super(operatorNode_1.OperatorIds.power, leftChild, rightChild, false, "^");
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return `(${this.leftChild})^{${this.rightChild}}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.PowerNode = PowerNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubstractNode = void 0;
|
|
4
|
+
const operatorNode_1 = require("./operatorNode");
|
|
5
|
+
class SubstractNode extends operatorNode_1.OperatorNode {
|
|
6
|
+
constructor(leftChild, rightChild) {
|
|
7
|
+
super(operatorNode_1.OperatorIds.substract, leftChild, rightChild, false, "-");
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return `${this.leftChild}-(${this.rightChild})`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SubstractNode = SubstractNode;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VariableNode = void 0;
|
|
4
|
+
const node_1 = require("../node");
|
|
5
|
+
class VariableNode {
|
|
6
|
+
constructor(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
|
+
toString() {
|
|
13
|
+
return `${this.tex}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.VariableNode = VariableNode;
|