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.
Files changed (216) hide show
  1. package/lib/exercises/calcul/addAndSub.js +40 -0
  2. package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -0
  3. package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +31 -0
  4. package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -0
  5. package/lib/exercises/calcul/fractions/fractionsDivision.js +29 -0
  6. package/lib/exercises/calcul/fractions/fractionsProduct.js +29 -0
  7. package/lib/exercises/calcul/fractions/fractionsSum.js +29 -0
  8. package/lib/exercises/calcul/fractions/simplifyFraction.js +25 -0
  9. package/lib/exercises/calcul/operations/operationsPriorities.js +88 -0
  10. package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +111 -0
  11. package/{src → lib}/exercises/calcul/operationsPriorities.js +88 -89
  12. package/{src → lib}/exercises/calcul/rounding/rounding.js +86 -87
  13. package/{src → lib}/exercises/calculLitteral/distributivity/allIdentities.js +27 -27
  14. package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +31 -0
  15. package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +32 -0
  16. package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +33 -0
  17. package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +33 -0
  18. package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +32 -0
  19. package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +38 -0
  20. package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +41 -0
  21. package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +42 -0
  22. package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +44 -0
  23. package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +39 -0
  24. package/{src → lib}/exercises/exercise.js +7 -7
  25. package/lib/exercises/exercises.js +95 -0
  26. package/lib/exercises/geometry/cartesian/midpoint.js +29 -0
  27. package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +29 -0
  28. package/lib/exercises/geometry/vectors/scalarProductViaNorms.js +27 -0
  29. package/lib/exercises/powers/powersDivision.js +45 -0
  30. package/lib/exercises/powers/powersOfTenToDecimal.js +33 -0
  31. package/lib/exercises/powers/powersPower.js +44 -0
  32. package/lib/exercises/powers/powersProduct.js +45 -0
  33. package/lib/exercises/powers/scientificToDecimal.js +38 -0
  34. package/{src → lib}/exercises/squareRoots/simpifySquareRoot.js +28 -28
  35. package/lib/exercises/utils/getDistinctQuestions.js +16 -0
  36. package/lib/geometry/point.js +27 -0
  37. package/lib/geometry/vector.js +31 -0
  38. package/lib/index.js +10 -0
  39. package/lib/mathutils/arithmetic/coprimesOf.js +13 -0
  40. package/lib/mathutils/arithmetic/dividersOf.js +12 -0
  41. package/{src → lib}/mathutils/arithmetic/gcd.js +7 -7
  42. package/{src → lib}/mathutils/arithmetic/isSquare.js +7 -7
  43. package/{src → lib}/mathutils/arithmetic/lcd.js +12 -12
  44. package/lib/mathutils/arithmetic/nonCoprimesOf.js +13 -0
  45. package/lib/mathutils/arithmetic/nonDividersOf.js +14 -0
  46. package/{src → lib}/mathutils/arithmetic/primeFactors.js +22 -22
  47. package/lib/mathutils/decimals/decimalPartLengthOf.js +14 -0
  48. package/lib/mathutils/random/randTupleInt.js +30 -0
  49. package/{src → lib}/mathutils/random/randint.js +18 -18
  50. package/{src → lib}/mathutils/round.js +8 -8
  51. package/{src → lib}/numbers/decimals/decimal.js +140 -144
  52. package/{src → lib}/numbers/epsilon.js +10 -10
  53. package/{src → lib}/numbers/integer/integer.js +68 -72
  54. package/{src → lib}/numbers/integer/power.js +52 -53
  55. package/{src → lib}/numbers/nombre.js +10 -10
  56. package/lib/numbers/rationals/rational.js +113 -0
  57. package/lib/numbers/reals/real.js +16 -0
  58. package/lib/numbers/reals/squareRoot.js +63 -0
  59. package/lib/polynomials/affine.js +42 -0
  60. package/lib/polynomials/polynomial.js +125 -0
  61. package/lib/sets/discreteSet.js +28 -0
  62. package/{src/sets/emptySet.ts → lib/sets/emptySet.js} +6 -6
  63. package/{src → lib}/sets/intervals/intervals.js +108 -113
  64. package/lib/sets/intervals/union.js +1 -0
  65. package/lib/sets/mathSet.js +10 -0
  66. package/lib/sets/mathSetInterface.js +2 -0
  67. package/{src → lib}/tree/nodes/functions/functionNode.js +18 -19
  68. package/lib/tree/nodes/functions/oppositeNode.js +13 -0
  69. package/lib/tree/nodes/functions/sqrtNode.js +15 -0
  70. package/{src → lib}/tree/nodes/node.js +10 -10
  71. package/lib/tree/nodes/numbers/numberNode.js +18 -0
  72. package/lib/tree/nodes/operators/addNode.js +15 -0
  73. package/lib/tree/nodes/operators/divideNode.js +17 -0
  74. package/lib/tree/nodes/operators/equalNode.js +13 -0
  75. package/lib/tree/nodes/operators/fractionNode.js +17 -0
  76. package/lib/tree/nodes/operators/multiplyNode.js +13 -0
  77. package/{src → lib}/tree/nodes/operators/operatorNode.js +35 -37
  78. package/lib/tree/nodes/operators/powerNode.js +13 -0
  79. package/lib/tree/nodes/operators/substractNode.js +13 -0
  80. package/lib/tree/nodes/variables/variableNode.js +16 -0
  81. package/{src → lib}/tree/parsers/derivateParser.js +60 -60
  82. package/{src → lib}/tree/parsers/latexParser.js +117 -117
  83. package/lib/utils/arrayEqual.js +13 -0
  84. package/{src → lib}/utils/coin.js +7 -7
  85. package/{src → lib}/utils/random.js +7 -7
  86. package/lib/utils/shuffle.js +15 -0
  87. package/package.json +35 -28
  88. package/nodemon.json +0 -5
  89. package/src/exercises/calcul/addAndSub.js +0 -40
  90. package/src/exercises/calcul/addAndSub.ts +0 -39
  91. package/src/exercises/calcul/fractions/fractionAndIntegerDivision.js +0 -35
  92. package/src/exercises/calcul/fractions/fractionAndIntegerDivision.ts +0 -36
  93. package/src/exercises/calcul/fractions/fractionAndIntegerProduct.js +0 -31
  94. package/src/exercises/calcul/fractions/fractionAndIntegerProduct.ts +0 -32
  95. package/src/exercises/calcul/fractions/fractionAndIntegerSum.js +0 -32
  96. package/src/exercises/calcul/fractions/fractionAndIntegerSum.ts +0 -31
  97. package/src/exercises/calcul/fractions/fractionsDivision.js +0 -29
  98. package/src/exercises/calcul/fractions/fractionsDivision.ts +0 -30
  99. package/src/exercises/calcul/fractions/fractionsProduct.js +0 -29
  100. package/src/exercises/calcul/fractions/fractionsProduct.ts +0 -29
  101. package/src/exercises/calcul/fractions/fractionsSum.js +0 -29
  102. package/src/exercises/calcul/fractions/fractionsSum.ts +0 -28
  103. package/src/exercises/calcul/fractions/simplifyFraction.js +0 -25
  104. package/src/exercises/calcul/fractions/simplifyFraction.ts +0 -24
  105. package/src/exercises/calcul/operationsPriorities.ts +0 -115
  106. package/src/exercises/calcul/rounding/rounding.ts +0 -87
  107. package/src/exercises/calculLitteral/distributivity/allIdentities.ts +0 -26
  108. package/src/exercises/calculLitteral/distributivity/doubleDistributivity.js +0 -31
  109. package/src/exercises/calculLitteral/distributivity/doubleDistributivity.ts +0 -33
  110. package/src/exercises/calculLitteral/distributivity/firstIdentity.js +0 -32
  111. package/src/exercises/calculLitteral/distributivity/firstIdentity.ts +0 -33
  112. package/src/exercises/calculLitteral/distributivity/secondIdentity.js +0 -33
  113. package/src/exercises/calculLitteral/distributivity/secondIdentity.ts +0 -35
  114. package/src/exercises/calculLitteral/distributivity/simpleDistributivity.js +0 -33
  115. package/src/exercises/calculLitteral/distributivity/simpleDistributivity.ts +0 -33
  116. package/src/exercises/calculLitteral/distributivity/thirdIdentity.js +0 -32
  117. package/src/exercises/calculLitteral/distributivity/thirdIdentity.ts +0 -34
  118. package/src/exercises/calculLitteral/equation/equationType1Exercise.js +0 -38
  119. package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +0 -38
  120. package/src/exercises/calculLitteral/equation/equationType2Exercise.js +0 -41
  121. package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +0 -41
  122. package/src/exercises/calculLitteral/equation/equationType3Exercise.js +0 -42
  123. package/src/exercises/calculLitteral/equation/equationType3Exercise.ts +0 -43
  124. package/src/exercises/calculLitteral/equation/equationType4Exercise.js +0 -44
  125. package/src/exercises/calculLitteral/equation/equationType4Exercise.ts +0 -46
  126. package/src/exercises/calculLitteral/factorisation/factoType1Exercise.js +0 -39
  127. package/src/exercises/calculLitteral/factorisation/factoType1Exercise.ts +0 -54
  128. package/src/exercises/exercise.ts +0 -22
  129. package/src/exercises/exercises.js +0 -85
  130. package/src/exercises/exercises.ts +0 -94
  131. package/src/exercises/powers/powersDivision.js +0 -46
  132. package/src/exercises/powers/powersDivision.ts +0 -51
  133. package/src/exercises/powers/powersOfTenToDecimal.js +0 -33
  134. package/src/exercises/powers/powersOfTenToDecimal.ts +0 -37
  135. package/src/exercises/powers/powersPower.js +0 -45
  136. package/src/exercises/powers/powersPower.ts +0 -55
  137. package/src/exercises/powers/powersProduct.js +0 -46
  138. package/src/exercises/powers/powersProduct.ts +0 -51
  139. package/src/exercises/powers/scientificToDecimal.js +0 -38
  140. package/src/exercises/powers/scientificToDecimal.ts +0 -44
  141. package/src/exercises/squareRoots/simpifySquareRoot.ts +0 -27
  142. package/src/exercises/utils/getDistinctQuestions.js +0 -18
  143. package/src/exercises/utils/getDistinctQuestions.ts +0 -14
  144. package/src/index.js +0 -5
  145. package/src/index.ts +0 -13
  146. package/src/mathutils/arithmetic/coprimesOf.js +0 -13
  147. package/src/mathutils/arithmetic/coprimesOf.ts +0 -9
  148. package/src/mathutils/arithmetic/dividersOf.ts +0 -7
  149. package/src/mathutils/arithmetic/gcd.ts +0 -3
  150. package/src/mathutils/arithmetic/isSquare.ts +0 -3
  151. package/src/mathutils/arithmetic/lcd.ts +0 -7
  152. package/src/mathutils/arithmetic/nonCoprimesOf.ts +0 -9
  153. package/src/mathutils/arithmetic/nonDividersOf.ts +0 -12
  154. package/src/mathutils/arithmetic/primeFactors.ts +0 -18
  155. package/src/mathutils/decimals/decimalPartLengthOf.ts +0 -10
  156. package/src/mathutils/random/randint.ts +0 -12
  157. package/src/mathutils/round.ts +0 -5
  158. package/src/numbers/decimals/decimal.ts +0 -140
  159. package/src/numbers/epsilon.ts +0 -7
  160. package/src/numbers/integer/integer.ts +0 -72
  161. package/src/numbers/integer/power.ts +0 -49
  162. package/src/numbers/nombre.ts +0 -15
  163. package/src/numbers/number.js +0 -8
  164. package/src/numbers/rationals/rational.js +0 -128
  165. package/src/numbers/rationals/rational.ts +0 -122
  166. package/src/numbers/reals/real.js +0 -17
  167. package/src/numbers/reals/real.ts +0 -17
  168. package/src/numbers/reals/squareRoot.js +0 -85
  169. package/src/numbers/reals/squareRoot.ts +0 -70
  170. package/src/polynomials/affine.js +0 -71
  171. package/src/polynomials/affine.ts +0 -60
  172. package/src/polynomials/polynomial.js +0 -128
  173. package/src/polynomials/polynomial.ts +0 -137
  174. package/src/sets/discreteSet.js +0 -30
  175. package/src/sets/discreteSet.ts +0 -30
  176. package/src/sets/intervals/intervals.ts +0 -122
  177. package/src/sets/intervals/union.ts +0 -0
  178. package/src/sets/mathSet.js +0 -11
  179. package/src/sets/mathSet.ts +0 -12
  180. package/src/sets/mathSetInterface.js +0 -2
  181. package/src/sets/mathSetInterface.ts +0 -10
  182. package/src/tree/latexParser/latexParse.js +0 -117
  183. package/src/tree/nodes/functions/functionNode.ts +0 -18
  184. package/src/tree/nodes/functions/oppositeNode.js +0 -30
  185. package/src/tree/nodes/functions/oppositeNode.ts +0 -12
  186. package/src/tree/nodes/functions/sqrtNode.js +0 -33
  187. package/src/tree/nodes/functions/sqrtNode.ts +0 -12
  188. package/src/tree/nodes/node.ts +0 -12
  189. package/src/tree/nodes/numbers/numberNode.js +0 -16
  190. package/src/tree/nodes/numbers/numberNode.ts +0 -16
  191. package/src/tree/nodes/operators/addNode.js +0 -33
  192. package/src/tree/nodes/operators/addNode.ts +0 -13
  193. package/src/tree/nodes/operators/divideNode.js +0 -34
  194. package/src/tree/nodes/operators/divideNode.ts +0 -16
  195. package/src/tree/nodes/operators/equalNode.js +0 -30
  196. package/src/tree/nodes/operators/equalNode.ts +0 -11
  197. package/src/tree/nodes/operators/fractionNode.js +0 -34
  198. package/src/tree/nodes/operators/fractionNode.ts +0 -16
  199. package/src/tree/nodes/operators/multiplyNode.js +0 -30
  200. package/src/tree/nodes/operators/multiplyNode.ts +0 -12
  201. package/src/tree/nodes/operators/operatorNode.ts +0 -36
  202. package/src/tree/nodes/operators/oppositeNode.js +0 -18
  203. package/src/tree/nodes/operators/powerNode.js +0 -30
  204. package/src/tree/nodes/operators/powerNode.ts +0 -12
  205. package/src/tree/nodes/operators/substractNode.js +0 -30
  206. package/src/tree/nodes/operators/substractNode.ts +0 -11
  207. package/src/tree/nodes/variables/variableNode.js +0 -17
  208. package/src/tree/nodes/variables/variableNode.ts +0 -15
  209. package/src/tree/parsers/derivateParser.ts +0 -66
  210. package/src/tree/parsers/latexParser.ts +0 -122
  211. package/src/utils/coin.ts +0 -3
  212. package/src/utils/random.ts +0 -3
  213. package/src/utils/randomIn.js +0 -7
  214. package/src/utils/shuffle.js +0 -24
  215. package/src/utils/shuffle.ts +0 -11
  216. 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
- // import { MathSetInterface } from "./mathSetInterface";
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.__esModule = true;
3
- exports.Interval = void 0;
4
- var epsilon_1 = require("../../numbers/epsilon");
5
- var nombre_1 = require("../../numbers/nombre");
6
- var round_1 = require("../../mathutils/round");
7
- var mathSet_1 = require("../mathSet");
8
- var integer_1 = require("../../numbers/integer/integer");
9
- var 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
- var Interval = /** @class */ (function () {
18
- /**
19
- * [[a; b]] pour un interval d'integer; [a;b] pour des réels
20
- */
21
- function Interval(tex) {
22
- if (tex === void 0) { tex = "[-10; 10]"; }
23
- this.tex = tex;
24
- var isInt = tex[1] === "[" || tex[1] === "]";
25
- this.type = isInt ? nombre_1.NumberType.Integer : nombre_1.NumberType.Real;
26
- var left = tex[0];
27
- var right = tex[tex.length - 1];
28
- var _a = tex
29
- .slice(isInt ? 2 : 1, isInt ? tex.length - 2 : tex.length - 1)
30
- .split(";"), a = _a[0], b = _a[1];
31
- switch ("".concat(left, "a;b").concat(right)) {
32
- case "[a;b]":
33
- this.boundType = BoundType.FF;
34
- break;
35
- case "]a;b[":
36
- this.boundType = BoundType.OO;
37
- break;
38
- case "[a;b[":
39
- this.boundType = BoundType.FO;
40
- break;
41
- case "]a;b]":
42
- this.boundType = BoundType.OF;
43
- break;
44
- default:
45
- throw console.error("wrong interval");
46
- }
47
- function getBound(bound) {
48
- return bound === "-\\infty"
49
- ? Number.NEGATIVE_INFINITY
50
- : bound === "+\\infty"
51
- ? Number.POSITIVE_INFINITY
52
- : Number(bound);
53
- }
54
- this.min = getBound(a);
55
- this.max = getBound(b);
56
- }
57
- // union(interval: Interval): MathSet {
58
- //[a,b] [c,d]
59
- //si a=c return a, max(b,d)
60
- //si si b = d return min(a,c), b
61
- //si a=d return c,b sauf si OXXO
62
- //si b=c return a,d sauf si XOOX
63
- //si c > b ou d < a alors union disjointe avec plus petit en 1er
64
- //sinon return min(a,c), max(b,d)
65
- //res = a
66
- // return new MathSet();
67
- // }
68
- Interval.prototype.exclude = function (nb) {
69
- var _this = this;
70
- var rand = function () {
71
- var x;
72
- do {
73
- x = _this.getRandomElement();
74
- } while (x.value === nb);
75
- return x;
76
- };
77
- return new mathSet_1.MathSet(this.toTex() + "\\{".concat(nb, "\\}"), rand);
78
- };
79
- Interval.prototype.difference = function (set) {
80
- var _this = this;
81
- var rand = function () {
82
- var x;
83
- do {
84
- x = _this.getRandomElement();
85
- } while (set.includes(x));
86
- return x;
87
- };
88
- return new mathSet_1.MathSet(this.toTex() + "\\ ".concat(set.toTex()), rand);
89
- };
90
- Interval.prototype.toTex = function () {
91
- return this.tex;
92
- };
93
- Interval.prototype.getRandomElement = function (precision) {
94
- if (precision === void 0) { precision = this.type === nombre_1.NumberType.Integer ? 0 : 2; }
95
- if (this.min === -Infinity || this.max === Infinity)
96
- throw Error("Can't chose amongst infinity");
97
- var min = this.boundType === BoundType.OO || this.boundType === BoundType.OF
98
- ? this.min + epsilon_1.EPSILON
99
- : this.min;
100
- var max = this.boundType === BoundType.OO || this.boundType === BoundType.FO
101
- ? this.max - epsilon_1.EPSILON
102
- : this.max;
103
- var value = (0, round_1.round)(min + Math.random() * (max - this.min), precision);
104
- switch (this.type) {
105
- case nombre_1.NumberType.Integer:
106
- return new integer_1.Integer(value);
107
- default:
108
- return new real_1.Real(value, value.toString());
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;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +1,18 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.FunctionNode = exports.FunctionsIds = void 0;
4
- var 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
- var FunctionNode = /** @class */ (function () {
11
- function FunctionNode(id, child, tex) {
12
- this.type = node_1.NodeType["function"];
13
- this.id = id;
14
- this.child = child;
15
- this.tex = tex;
16
- }
17
- return FunctionNode;
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.__esModule = 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 = {}));
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.__esModule = true;
3
- exports.OperatorNode = exports.OperatorIds = void 0;
4
- var coin_1 = require("../../../utils/coin");
5
- var 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
- var OperatorNode = /** @class */ (function () {
17
- function OperatorNode(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
- OperatorNode.prototype.shuffle = function () {
27
- var _a;
28
- if (!this.isCommutative)
29
- return this;
30
- if ((0, coin_1.coin)())
31
- return this;
32
- _a = [this.rightChild, this.leftChild], this.leftChild = _a[0], this.rightChild = _a[1];
33
- return this;
34
- };
35
- return OperatorNode;
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;