math-exercises 3.0.10 → 3.0.12

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 (153) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionsOperations.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/fractions/fractionsOperations.js +0 -1
  3. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +17 -15
  5. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +1 -1
  6. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -1
  7. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +17 -3
  8. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +6 -2
  10. package/lib/exercises/math/functions/basics/inverseImageFunction.d.ts +2 -2
  11. package/lib/exercises/math/functions/basics/inverseImageFunction.d.ts.map +1 -1
  12. package/lib/exercises/math/functions/basics/inverseImageFunction.js +81 -14
  13. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts +11 -0
  14. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts.map +1 -0
  15. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.js +134 -0
  16. package/lib/exercises/math/functions/trinoms/devForm/index.d.ts +3 -0
  17. package/lib/exercises/math/functions/trinoms/devForm/index.d.ts.map +1 -0
  18. package/lib/exercises/math/functions/trinoms/devForm/index.js +2 -0
  19. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts +9 -0
  20. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -0
  21. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +42 -0
  22. package/lib/exercises/math/functions/trinoms/equation/deltaTrinom.d.ts +9 -0
  23. package/lib/exercises/math/functions/trinoms/equation/deltaTrinom.d.ts.map +1 -0
  24. package/lib/exercises/math/functions/trinoms/equation/deltaTrinom.js +50 -0
  25. package/lib/exercises/math/functions/trinoms/equation/index.d.ts +5 -0
  26. package/lib/exercises/math/functions/trinoms/equation/index.d.ts.map +1 -0
  27. package/lib/exercises/math/functions/trinoms/equation/index.js +4 -0
  28. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.d.ts +11 -0
  29. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.js +102 -0
  31. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts +9 -0
  32. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.js +131 -0
  34. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts +7 -0
  35. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -0
  36. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +69 -0
  37. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts +8 -0
  38. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts.map +1 -0
  39. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.js +72 -0
  40. package/lib/exercises/math/functions/trinoms/factoForm/index.d.ts +2 -0
  41. package/lib/exercises/math/functions/trinoms/factoForm/index.d.ts.map +1 -0
  42. package/lib/exercises/math/functions/trinoms/factoForm/index.js +1 -0
  43. package/lib/exercises/math/functions/trinoms/index.d.ts +7 -23
  44. package/lib/exercises/math/functions/trinoms/index.d.ts.map +1 -1
  45. package/lib/exercises/math/functions/trinoms/index.js +7 -23
  46. package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +3 -0
  47. package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -0
  48. package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
  49. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts +8 -0
  50. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts.map +1 -0
  51. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.js +285 -0
  52. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.d.ts +9 -0
  53. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.d.ts.map +1 -0
  54. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.js +112 -0
  55. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.d.ts +10 -0
  56. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.d.ts.map +1 -0
  57. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.js +124 -0
  58. package/lib/exercises/math/functions/trinoms/roots/index.d.ts +8 -0
  59. package/lib/exercises/math/functions/trinoms/roots/index.d.ts.map +1 -0
  60. package/lib/exercises/math/functions/trinoms/roots/index.js +7 -0
  61. package/lib/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.d.ts +9 -0
  62. package/lib/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.d.ts.map +1 -0
  63. package/lib/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.js +54 -0
  64. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts +9 -0
  65. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts.map +1 -0
  66. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.js +55 -0
  67. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts +9 -0
  68. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts.map +1 -0
  69. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.js +67 -0
  70. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.d.ts +8 -0
  71. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.d.ts.map +1 -0
  72. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.js +109 -0
  73. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts +9 -0
  74. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -0
  75. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +63 -0
  76. package/lib/exercises/math/functions/trinoms/roots/rootsSum.d.ts +8 -0
  77. package/lib/exercises/math/functions/trinoms/roots/rootsSum.d.ts.map +1 -0
  78. package/lib/exercises/math/functions/trinoms/roots/rootsSum.js +109 -0
  79. package/lib/exercises/math/functions/trinoms/sign/index.d.ts +3 -0
  80. package/lib/exercises/math/functions/trinoms/sign/index.d.ts.map +1 -0
  81. package/lib/exercises/math/functions/trinoms/sign/index.js +2 -0
  82. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts +8 -0
  83. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -0
  84. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +120 -0
  85. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.d.ts +8 -0
  86. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.d.ts.map +1 -0
  87. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.js +119 -0
  88. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaFromDevForm.d.ts +8 -0
  89. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaFromDevForm.d.ts.map +1 -0
  90. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaFromDevForm.js +49 -0
  91. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaInCanonicalForm.d.ts +10 -0
  92. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaInCanonicalForm.d.ts.map +1 -0
  93. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaInCanonicalForm.js +64 -0
  94. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts +9 -0
  95. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts.map +1 -0
  96. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.js +48 -0
  97. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts +9 -0
  98. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts.map +1 -0
  99. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.js +55 -0
  100. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +9 -0
  101. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -0
  102. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +42 -0
  103. package/lib/exercises/math/functions/trinoms/summitAndCanonical/index.d.ts +9 -0
  104. package/lib/exercises/math/functions/trinoms/summitAndCanonical/index.d.ts.map +1 -0
  105. package/lib/exercises/math/functions/trinoms/summitAndCanonical/index.js +8 -0
  106. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromDevForm.d.ts +9 -0
  107. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromDevForm.d.ts.map +1 -0
  108. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromDevForm.js +90 -0
  109. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromRoots.d.ts +9 -0
  110. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromRoots.d.ts.map +1 -0
  111. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromRoots.js +55 -0
  112. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts +9 -0
  113. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts.map +1 -0
  114. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.js +59 -0
  115. package/lib/exercises/math/geometry/areas/triangleArea.d.ts +2 -0
  116. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  117. package/lib/exercises/math/geometry/areas/triangleArea.js +56 -31
  118. package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.d.ts.map +1 -1
  119. package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.js +34 -14
  120. package/lib/exercises/math/trigonometry/equationCosOnRandomInterval.js +10 -10
  121. package/lib/exercises/math/trigonometry/equationSinOnRandomInterval.js +10 -10
  122. package/lib/exercises/math/trigonometry/mainAngleMeasure.d.ts.map +1 -1
  123. package/lib/exercises/math/trigonometry/mainAngleMeasure.js +1 -0
  124. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts.map +1 -1
  125. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +170 -106
  126. package/lib/exercises/vea/numberVEA.d.ts +1 -1
  127. package/lib/exercises/vea/numberVEA.d.ts.map +1 -1
  128. package/lib/exercises/vea/numberVEA.js +2 -2
  129. package/lib/index.d.ts +44 -33
  130. package/lib/index.d.ts.map +1 -1
  131. package/lib/math/geometry/triangle.d.ts +1 -0
  132. package/lib/math/geometry/triangle.d.ts.map +1 -1
  133. package/lib/math/geometry/triangle.js +10 -2
  134. package/lib/math/polynomials/affine.d.ts +2 -0
  135. package/lib/math/polynomials/affine.d.ts.map +1 -1
  136. package/lib/math/polynomials/affine.js +5 -0
  137. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  138. package/lib/tests/questionTest.d.ts.map +1 -1
  139. package/lib/tests/questionTest.js +1 -1
  140. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  141. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  142. package/lib/tree/nodes/equations/equalNode.d.ts +1 -2
  143. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  144. package/lib/tree/nodes/equations/equalNode.js +47 -22
  145. package/lib/tree/nodes/polynomials/trinomNode.d.ts +1 -0
  146. package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -1
  147. package/lib/tree/nodes/polynomials/trinomNode.js +9 -0
  148. package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
  149. package/lib/tree/nodes/variables/variableNode.js +1 -3
  150. package/lib/tree/parsers/numberParser.d.ts +1 -1
  151. package/lib/tree/parsers/numberParser.d.ts.map +1 -1
  152. package/lib/tree/parsers/numberParser.js +4 -1
  153. package/package.json +1 -1
@@ -1,6 +1,12 @@
1
1
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
2
+ import { alignTex } from "../../../utils/latex/alignTex.js";
2
3
  import { NodeIds, NodeType } from "../node.js";
3
4
  import { NodeConstructor } from "../nodeConstructor.js";
5
+ import { add } from "../operators/addNode.js";
6
+ import { frac } from "../operators/fractionNode.js";
7
+ import { multiply } from "../operators/multiplyNode.js";
8
+ import { substract } from "../operators/substractNode.js";
9
+ import { monom } from "../polynomials/monomNode.js";
4
10
  export const equal = (a, b) => {
5
11
  const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
6
12
  const nodeB = typeof b === "number" ? b.toTree() : typeof b === "string" ? b.toTree() : b;
@@ -67,26 +73,45 @@ export class EqualNode {
67
73
  return new EqualNode(this.rightChild, this.leftChild, this.opts);
68
74
  }
69
75
  }
70
- export const firstDegreeEquationResolutionTex = (affineLeft, affineRight) => {
71
- //ax(+-b) = (+-c)(x)(+-d)
72
- // const b = affine.b;
73
- // const a = affine.a;
74
- // if (a === 1 && b === 0)
75
- // return new InequationNode([affine.toTree(), right], [order]).toTex();
76
- // const steps: string[][] = [[affine.toTex(), order, right.toTex()]];
77
- // if (b !== 0)
78
- // steps.push([
79
- // affine.add(-b).toTex(),
80
- // order,
81
- // substract(right, b).simplify().toTex(),
82
- // ]);
83
- // if (a !== 1) {
84
- // if (a < 0) order = new InequationSymbol(order).reversed();
85
- // steps.push([
86
- // affine.variable,
87
- // order,
88
- // frac(substract(right, b), a).simplify().toTex(),
89
- // ]);
90
- // }
91
- // return alignTex(steps, true);
76
+ export const equationResolutionTex = (a, b, c, d) => {
77
+ //(+-a)x(+-b) = (+-c)x(+-d)
78
+ const steps = [];
79
+ const iteration = (a, b, c, d) => {
80
+ const aEv = a.evaluate();
81
+ const bEv = b.evaluate();
82
+ const cEv = c.evaluate();
83
+ if (bEv === 0) {
84
+ if (cEv === 0) {
85
+ //ax = d
86
+ if (aEv === 1) {
87
+ //x = d
88
+ steps.push(`x=${d.toTex()}`);
89
+ return;
90
+ }
91
+ else {
92
+ //ax = d
93
+ steps.push(`${multiply(a, "x").toTex()}=${d.toTex()}`);
94
+ iteration((1).toTree(), (0).toTree(), (0).toTree(), frac(d, a).simplify());
95
+ }
96
+ }
97
+ else {
98
+ steps.push(`${monom(a, 1).toTex()}=${add(monom(c, 1), d).toTex()}`);
99
+ //ax = c!x + d
100
+ iteration(substract(a, c).simplify(), (0).toTree(), (0).toTree(), d);
101
+ }
102
+ }
103
+ else {
104
+ //ax + b! = cx + d
105
+ steps.push(`${add(multiply(a, "x"), b).simplify().toTex()}=${add(multiply(c, "x"), d)
106
+ .simplify()
107
+ .toTex()}`);
108
+ iteration(a, (0).toTree(), c, substract(d, b).simplify());
109
+ }
110
+ };
111
+ iteration(a, b, c, d);
112
+ if (steps.length === 1) {
113
+ return steps[0];
114
+ }
115
+ return alignTex(steps.map((e) => [e.split("=")[0], "=", e.split("=")[1]]), true);
116
+ return steps;
92
117
  };
@@ -62,6 +62,7 @@ export declare class TrinomNode implements AlgebraicNode {
62
62
  toMathString(): string;
63
63
  getRoots(): AlgebraicNode[];
64
64
  toTree(): import("../../../tree/nodes/operators/addNode.js").AddNode | import("../../../tree/nodes/operators/multiplyNode.js").MultiplyNode;
65
+ toFactorized(): AlgebraicNode | import("../../../tree/nodes/operators/addNode.js").AddNode | import("../../../tree/nodes/operators/multiplyNode.js").MultiplyNode;
65
66
  toTex(): string;
66
67
  getCoeffs(): number[];
67
68
  toIdentifiers(): TrinomNodeIdentifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"trinomNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/polynomials/trinomNode.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACb,eAAe,EAChB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAE7C,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,MAAM,CACX,KAAK,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,EAC3D,KAAK,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,EAC3D,KAAK,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAC1D,UAAU;IAmBb,MAAM,CAAC,eAAe,CACpB,KAAK,CAAC,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KACjB,EACD,SAAS,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MA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AAa,GAAG,MAAM,EACzB,CAAC,EAAE,aAAa,GAAG,MAAM,EACzB,IAAI,CAAC,EAAE,iBAAiB;IAU1B,QAAQ;IAgBR,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;IAGvC,MAAM,CAAC,IAAI,EAAE,aAAa;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAG/B,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS;IAG7C,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS;IAGhD,YAAY;IAIZ,QAAQ,IAAI,aAAa,EAAE;IAgB3B,MAAM;IAYN,YAAY;IAiBZ,KAAK;IAGL,SAAS;IAIT,aAAa,IAAI,qBAAqB;CASvC"}
@@ -138,6 +138,15 @@ export class TrinomNode {
138
138
  return add(highMonom, this.c);
139
139
  return add(highMonom, add(middleMonom, this.c));
140
140
  }
141
+ toFactorized() {
142
+ const roots = this.getRoots();
143
+ if (!roots.length)
144
+ return this.toTree();
145
+ if (roots.length === 1) {
146
+ return multiply(this.a, square(substract(this.variable, roots[0]))).simplify();
147
+ }
148
+ return multiply(this.a, multiply(substract(this.variable, roots[0]), substract(this.variable, roots[1]))).simplify();
149
+ }
141
150
  toTex() {
142
151
  return this.toTree().toTex();
143
152
  }
@@ -1 +1 @@
1
- {"version":3,"file":"variableNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/variables/variableNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI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,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAKxD"}
@@ -47,9 +47,7 @@ export class VariableNode {
47
47
  return isVariableNode(node) && node.name === this.name;
48
48
  }
49
49
  toDetailedEvaluation(vars) {
50
- if (!vars[this.name])
51
- throw Error("Detailed Evaluation variable non handled");
52
- return vars[this.name];
50
+ return vars[this.name] ?? this;
53
51
  }
54
52
  derivative(varName) {
55
53
  const variable = varName ?? "x";
@@ -1,2 +1,2 @@
1
- export declare const numberParser: (ans: string) => string | false;
1
+ export declare const numberParser: (ans: string, roundTo?: number) => string | false;
2
2
  //# sourceMappingURL=numberParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"numberParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/numberParser.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,QAAS,MAAM,mBAIvC,CAAC"}
1
+ {"version":3,"file":"numberParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/numberParser.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,QAAS,MAAM,YAAY,MAAM,mBAKzD,CAAC"}
@@ -1,7 +1,10 @@
1
+ import { round } from "../../math/utils/round.js";
1
2
  //returns false if ans is NaN (even in french form) and returns the frenchified form otherwise
2
- export const numberParser = (ans) => {
3
+ export const numberParser = (ans, roundTo) => {
3
4
  const nb = ans.unfrenchify();
4
5
  if (isNaN(nb))
5
6
  return false;
7
+ if (roundTo !== undefined)
8
+ return round(nb, roundTo).frenchify();
6
9
  return nb.frenchify();
7
10
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.10",
4
+ "version": "3.0.12",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [