math-exercises 3.0.125 → 3.0.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +61 -1
- package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +1 -0
- package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/index.js +1 -0
- package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +15 -0
- package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -0
- package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +217 -0
- package/lib/exercises/math/calcul/ordering/compareA10N.d.ts +16 -0
- package/lib/exercises/math/calcul/ordering/compareA10N.d.ts.map +1 -0
- package/lib/exercises/math/calcul/ordering/compareA10N.js +327 -0
- package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.d.ts +8 -0
- package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.d.ts.map +1 -0
- package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.js +221 -0
- package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts +9 -0
- package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts.map +1 -0
- package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.js +135 -0
- package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts +29 -0
- package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts.map +1 -0
- package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +367 -0
- package/lib/exercises/math/calcul/ordering/comparePowersOfFracs.d.ts +12 -0
- package/lib/exercises/math/calcul/ordering/comparePowersOfFracs.d.ts.map +1 -0
- package/lib/exercises/math/calcul/ordering/comparePowersOfFracs.js +164 -0
- package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.d.ts +9 -0
- package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.d.ts.map +1 -0
- package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.js +140 -0
- package/lib/exercises/math/calcul/ordering/index.d.ts +6 -0
- package/lib/exercises/math/calcul/ordering/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/ordering/index.js +6 -0
- package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.d.ts +9 -0
- package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.d.ts.map +1 -0
- package/lib/exercises/math/calcul/rounding/estimateAroundPow10NTimesAroundPow10N.js +84 -0
- package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts +8 -0
- package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts.map +1 -0
- package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.js +90 -0
- package/lib/exercises/math/calcul/rounding/index.d.ts +2 -0
- package/lib/exercises/math/calcul/rounding/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/rounding/index.js +2 -0
- package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts +13 -0
- package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +414 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factorizeAX2PlusBX.d.ts +10 -0
- package/lib/exercises/math/calculLitteral/factorisation/factorizeAX2PlusBX.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factorizeAX2PlusBX.js +70 -0
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -0
- package/lib/exercises/math/calculLitteral/index.d.ts +2 -0
- package/lib/exercises/math/calculLitteral/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/index.js +2 -0
- package/lib/exercises/math/calculLitteral/isolate/index.d.ts +2 -1
- package/lib/exercises/math/calculLitteral/isolate/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/isolate/index.js +2 -1
- package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.d.ts +8 -0
- package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.js +107 -0
- package/lib/exercises/math/calculLitteral/isolate/isolateXInInvXPlusInvYEqualsInvU.d.ts +7 -0
- package/lib/exercises/math/calculLitteral/isolate/isolateXInInvXPlusInvYEqualsInvU.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/isolate/isolateXInInvXPlusInvYEqualsInvU.js +80 -0
- package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.d.ts +10 -0
- package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +182 -0
- package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.d.ts +9 -0
- package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.js +144 -0
- package/lib/exercises/math/calculLitteral/ordering/index.d.ts +3 -0
- package/lib/exercises/math/calculLitteral/ordering/index.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/ordering/index.js +2 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts +11 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.js +120 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareFracXA.d.ts +8 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareFracXA.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareFracXA.js +67 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.d.ts +11 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +114 -0
- package/lib/exercises/math/calculLitteral/simplifying/index.d.ts +5 -0
- package/lib/exercises/math/calculLitteral/simplifying/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/index.js +5 -0
- package/lib/exercises/math/calculLitteral/simplifying/pickSameAsAPercentOfB.d.ts +13 -0
- package/lib/exercises/math/calculLitteral/simplifying/pickSameAsAPercentOfB.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/pickSameAsAPercentOfB.js +125 -0
- package/lib/exercises/math/calculLitteral/simplifying/pickSameAsInverseOfFracAB.d.ts +14 -0
- package/lib/exercises/math/calculLitteral/simplifying/pickSameAsInverseOfFracAB.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/pickSameAsInverseOfFracAB.js +148 -0
- package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts +5 -27
- package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.js +178 -241
- package/lib/exercises/math/conversion/index.d.ts +4 -0
- package/lib/exercises/math/conversion/index.d.ts.map +1 -1
- package/lib/exercises/math/conversion/index.js +4 -0
- package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.d.ts +8 -0
- package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.d.ts.map +1 -0
- package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.js +98 -0
- package/lib/exercises/math/conversion/minutesToHours.d.ts +10 -0
- package/lib/exercises/math/conversion/minutesToHours.d.ts.map +1 -0
- package/lib/exercises/math/conversion/minutesToHours.js +150 -0
- package/lib/exercises/math/conversion/prefixToNumber.d.ts +15 -0
- package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -0
- package/lib/exercises/math/conversion/prefixToNumber.js +233 -0
- package/lib/exercises/math/conversion/secondsToHours.d.ts +10 -0
- package/lib/exercises/math/conversion/secondsToHours.d.ts.map +1 -0
- package/lib/exercises/math/conversion/secondsToHours.js +150 -0
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts +50 -0
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +517 -0
- package/lib/exercises/math/dataRepresentations/boxPlotInterpreting.d.ts +7 -0
- package/lib/exercises/math/dataRepresentations/boxPlotInterpreting.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/boxPlotInterpreting.js +223 -0
- package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.d.ts +10 -0
- package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.js +139 -0
- package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.d.ts +8 -0
- package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.js +133 -0
- package/lib/exercises/math/dataRepresentations/graphReading.d.ts +8 -0
- package/lib/exercises/math/dataRepresentations/graphReading.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/graphReading.js +136 -0
- package/lib/exercises/math/dataRepresentations/halfPieChartCommenting.d.ts +18 -0
- package/lib/exercises/math/dataRepresentations/halfPieChartCommenting.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/halfPieChartCommenting.js +228 -0
- package/lib/exercises/math/dataRepresentations/halfPieChartReading.d.ts +8 -0
- package/lib/exercises/math/dataRepresentations/halfPieChartReading.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/halfPieChartReading.js +213 -0
- package/lib/exercises/math/dataRepresentations/histogramReading.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/histogramReading.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/histogramReading.js +163 -0
- package/lib/exercises/math/dataRepresentations/index.d.ts +10 -0
- package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/index.js +10 -0
- package/lib/exercises/math/dataRepresentations/plausibleGraph.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/plausibleGraph.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/plausibleGraph.js +145 -0
- package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/scatterPlotCommenting.js +308 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +5 -6
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts +8 -0
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.js +103 -0
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.d.ts +8 -0
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.js +100 -0
- package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts +16 -0
- package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.js +215 -0
- package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts +13 -0
- package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.js +206 -0
- package/lib/exercises/math/functions/affines/index.d.ts +7 -0
- package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/index.js +7 -0
- package/lib/exercises/math/functions/affines/recognizeExprAffine.d.ts +20 -0
- package/lib/exercises/math/functions/affines/recognizeExprAffine.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/recognizeExprAffine.js +284 -0
- package/lib/exercises/math/functions/affines/representationOfAffine.d.ts +13 -0
- package/lib/exercises/math/functions/affines/representationOfAffine.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/representationOfAffine.js +184 -0
- package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.d.ts +14 -0
- package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.d.ts.map +1 -0
- package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.js +216 -0
- package/lib/exercises/math/functions/basics/index.d.ts +1 -0
- package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/index.js +1 -0
- package/lib/exercises/math/functions/composition/functionComposition.d.ts +8 -0
- package/lib/exercises/math/functions/composition/functionComposition.d.ts.map +1 -0
- package/lib/exercises/math/functions/composition/functionComposition.js +238 -0
- package/lib/exercises/math/functions/composition/index.d.ts +2 -0
- package/lib/exercises/math/functions/composition/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/composition/index.js +1 -0
- package/lib/exercises/math/functions/index.d.ts +1 -0
- package/lib/exercises/math/functions/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/index.js +1 -0
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts +23 -0
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -0
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +448 -0
- package/lib/exercises/math/geometry/angles/index.js +2 -0
- package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts +23 -0
- package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts.map +1 -0
- package/lib/exercises/math/geometry/angles/isParallelUsingAngles.js +402 -0
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts +9 -6
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +140 -60
- package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +1 -1
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.js +121 -104
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.js +3 -2
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/index.js +1 -0
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts +0 -1
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +42 -80
- package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.d.ts +9 -0
- package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +217 -0
- package/lib/exercises/math/probaStat/index.d.ts +2 -0
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +2 -0
- package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +30 -0
- package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +548 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts +2 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/index.js +2 -0
- package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.d.ts +9 -0
- package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.js +90 -0
- package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts +10 -0
- package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +151 -0
- package/lib/exercises/pc/electricity/calculateUEqualsRI.d.ts +7 -0
- package/lib/exercises/pc/electricity/calculateUEqualsRI.d.ts.map +1 -0
- package/lib/exercises/pc/electricity/calculateUEqualsRI.js +73 -0
- package/lib/exercises/pc/electricity/index.d.ts +1 -0
- package/lib/exercises/pc/electricity/index.d.ts.map +1 -1
- package/lib/exercises/pc/electricity/index.js +1 -0
- package/lib/exercises/pc/index.d.ts +1 -0
- package/lib/exercises/pc/index.d.ts.map +1 -1
- package/lib/exercises/pc/index.js +1 -0
- package/lib/exercises/pc/moleculeFormula.d.ts.map +1 -1
- package/lib/exercises/pc/moleculeFormula.js +4 -3
- package/lib/exercises/pc/optics/index.d.ts +2 -0
- package/lib/exercises/pc/optics/index.d.ts.map +1 -0
- package/lib/exercises/pc/optics/index.js +1 -0
- package/lib/exercises/pc/optics/lensFormula.d.ts +21 -0
- package/lib/exercises/pc/optics/lensFormula.d.ts.map +1 -0
- package/lib/exercises/pc/optics/lensFormula.js +415 -0
- package/lib/exercises/pc/weight/calculateWeight.d.ts +8 -1
- package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
- package/lib/exercises/pc/weight/calculateWeight.js +113 -38
- package/lib/geogebra/parsers/geogebraParser.d.ts +4 -0
- package/lib/geogebra/parsers/geogebraParser.d.ts.map +1 -1
- package/lib/geogebra/parsers/geogebraParser.js +17 -0
- package/lib/index.d.ts +346 -12
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +1 -0
- package/lib/math/geometry/CloudPoints.d.ts +10 -0
- package/lib/math/geometry/CloudPoints.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.js +119 -0
- package/lib/math/geometry/line.d.ts +1 -0
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +10 -2
- package/lib/math/geometry/vector.d.ts +1 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +12 -0
- package/lib/math/progCalc/progCalc.d.ts +46 -0
- package/lib/math/progCalc/progCalc.d.ts.map +1 -0
- package/lib/math/progCalc/progCalc.js +239 -0
- package/lib/math/utils/latex/realize.d.ts +12 -0
- package/lib/math/utils/latex/realize.d.ts.map +1 -0
- package/lib/math/utils/latex/realize.js +43 -0
- package/lib/pc/constants/molecularChemistry/molecule.d.ts +2 -0
- package/lib/pc/constants/molecularChemistry/molecule.d.ts.map +1 -1
- package/lib/pc/constants/molecularChemistry/molecule.js +52 -0
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +1 -1
- package/lib/tests/singleExo.test.js +3 -3
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts +4 -2
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +8 -17
- package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +5 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +4 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +8 -17
- package/lib/tree/nodes/operators/operatorNode.d.ts +3 -3
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/variables/variableNode.d.ts +1 -1
- package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
- package/lib/tree/utilities/nodeShuffler.d.ts +12 -0
- package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -0
- package/lib/tree/utilities/nodeShuffler.js +123 -0
- package/lib/utils/arrays/getAllPicks.d.ts +2 -0
- package/lib/utils/arrays/getAllPicks.d.ts.map +1 -0
- package/lib/utils/arrays/getAllPicks.js +17 -0
- package/lib/utils/errors/handleVEAError.d.ts +1 -1
- package/lib/utils/errors/handleVEAError.d.ts.map +1 -1
- package/lib/utils/strings/decapitalize.d.ts +2 -0
- package/lib/utils/strings/decapitalize.d.ts.map +1 -0
- package/lib/utils/strings/decapitalize.js +3 -0
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ import { AddNode } from "../../tree/nodes/operators/addNode.js";
|
|
|
7
7
|
import { randint } from "../utils/random/randint.js";
|
|
8
8
|
import { covarianceXY } from "../utils/stats/covariance.js";
|
|
9
9
|
import { variance } from "../utils/stats/variance.js";
|
|
10
|
+
import { randfloat } from "../utils/random/randfloat.js";
|
|
11
|
+
import { coinFlip } from "../../utils/alea/coinFlip.js";
|
|
10
12
|
export class CloudPointsConstructor {
|
|
11
13
|
static random(nbPoints) {
|
|
12
14
|
const names = [];
|
|
@@ -32,6 +34,99 @@ export class CloudPointsConstructor {
|
|
|
32
34
|
});
|
|
33
35
|
return new CloudPoints(points);
|
|
34
36
|
}
|
|
37
|
+
static randomWithEvolutionType(nbPoints, evolutionType) {
|
|
38
|
+
const boxRunning = {
|
|
39
|
+
xMin: 0,
|
|
40
|
+
xMax: 0.5,
|
|
41
|
+
yMin: 0,
|
|
42
|
+
yMax: 1,
|
|
43
|
+
};
|
|
44
|
+
let firstPoint;
|
|
45
|
+
switch (evolutionType) {
|
|
46
|
+
case "increasing":
|
|
47
|
+
{
|
|
48
|
+
firstPoint = new Point("P_0", boxRunning.xMin, boxRunning.yMin);
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case "decreasing":
|
|
52
|
+
{
|
|
53
|
+
firstPoint = new Point("P_0", boxRunning.xMin, boxRunning.yMax);
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case "scatter":
|
|
57
|
+
default:
|
|
58
|
+
{
|
|
59
|
+
firstPoint = new Point("P_0", boxRunning.xMin, randfloat(boxRunning.yMin, boxRunning.yMax));
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
const points = [firstPoint];
|
|
64
|
+
const zeroOne = coinFlip() ? 0 : 1;
|
|
65
|
+
for (let i = 0; i < nbPoints - 1; i++) {
|
|
66
|
+
const point = new Point(`P_${i}`, randfloat(boxRunning.xMin, boxRunning.xMax), randfloat(boxRunning.yMin, boxRunning.yMax));
|
|
67
|
+
boxRunning.xMin = point.x.evaluate();
|
|
68
|
+
boxRunning.xMax = boxRunning.xMax + 0.5 / (nbPoints - 1);
|
|
69
|
+
switch (evolutionType) {
|
|
70
|
+
case "increasing":
|
|
71
|
+
{
|
|
72
|
+
boxRunning.yMin = point.y.evaluate();
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case "decreasing":
|
|
76
|
+
{
|
|
77
|
+
boxRunning.yMax = point.y.evaluate();
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case "scatter":
|
|
81
|
+
{
|
|
82
|
+
if (i % 2 === zeroOne) {
|
|
83
|
+
boxRunning.yMin = point.y.evaluate();
|
|
84
|
+
boxRunning.yMax = 1;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
boxRunning.yMin = 0;
|
|
88
|
+
boxRunning.yMax = point.y.evaluate();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
points.push(point);
|
|
94
|
+
}
|
|
95
|
+
return new CloudPoints(points);
|
|
96
|
+
}
|
|
97
|
+
static cloudPointsByReboxingCloudPoints(cloudPoints, boxTarget) {
|
|
98
|
+
const boxFrom = { xMin: NaN, xMax: NaN, yMin: NaN, yMax: NaN };
|
|
99
|
+
cloudPoints.points.forEach((point, i) => {
|
|
100
|
+
const x = point.x.evaluate();
|
|
101
|
+
const y = point.y.evaluate();
|
|
102
|
+
boxFrom.xMin = i === 0 ? x : Math.min(x, boxFrom.xMin);
|
|
103
|
+
boxFrom.xMax = i === 0 ? x : Math.max(x, boxFrom.xMax);
|
|
104
|
+
boxFrom.yMin = i === 0 ? y : Math.min(y, boxFrom.yMin);
|
|
105
|
+
boxFrom.yMax = i === 0 ? y : Math.max(y, boxFrom.yMax);
|
|
106
|
+
});
|
|
107
|
+
//allow zero slope: prevent overboxing
|
|
108
|
+
const boxFromYXRatio = (boxFrom.yMax - boxFrom.yMin) / (boxFrom.xMax - boxFrom.xMin);
|
|
109
|
+
if (boxFromYXRatio < 0.33) {
|
|
110
|
+
boxFrom.yMin =
|
|
111
|
+
boxFrom.yMin - (boxFrom.yMax - boxFrom.yMin) / boxFromYXRatio;
|
|
112
|
+
boxFrom.yMax =
|
|
113
|
+
boxFrom.yMax + (boxFrom.yMax - boxFrom.yMin) / boxFromYXRatio;
|
|
114
|
+
}
|
|
115
|
+
const pointsReboxed = cloudPoints.points.map((point) => {
|
|
116
|
+
const x = point.x.evaluate();
|
|
117
|
+
const y = point.y.evaluate();
|
|
118
|
+
const progressX = (x - boxFrom.xMin) / (boxFrom.xMax - boxFrom.xMin);
|
|
119
|
+
const progressY = (y - boxFrom.yMin) / (boxFrom.yMax - boxFrom.yMin);
|
|
120
|
+
const xReboxed = boxTarget.xMin + progressX * (boxTarget.xMax - boxTarget.xMin);
|
|
121
|
+
const yReboxed = boxTarget.yMin + progressY * (boxTarget.yMax - boxTarget.yMin);
|
|
122
|
+
return new Point(point.name, xReboxed, yReboxed);
|
|
123
|
+
});
|
|
124
|
+
return new CloudPoints(pointsReboxed);
|
|
125
|
+
}
|
|
126
|
+
static fromIdentifiers(cloudPointsIdentifiers) {
|
|
127
|
+
const points = cloudPointsIdentifiers.pointsIdentifiers.map((pIds) => PointConstructor.fromIdentifiers(pIds));
|
|
128
|
+
return new CloudPoints(points);
|
|
129
|
+
}
|
|
35
130
|
}
|
|
36
131
|
export class CloudPoints {
|
|
37
132
|
points;
|
|
@@ -74,6 +169,11 @@ export class CloudPoints {
|
|
|
74
169
|
const b = avgY - a * avgX;
|
|
75
170
|
return new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(+a.toFixed(2)), new VariableNode("x")).simplify(), new NumberNode(+b.toFixed(2))));
|
|
76
171
|
}
|
|
172
|
+
getSlopeNode() {
|
|
173
|
+
const equalNode = this.getFineAdjustement();
|
|
174
|
+
return equalNode.rightChild.leftChild
|
|
175
|
+
.leftChild;
|
|
176
|
+
}
|
|
77
177
|
getCorrelationCoeff() {
|
|
78
178
|
const xValues = this.points.map((point) => {
|
|
79
179
|
return point.getXnumber();
|
|
@@ -92,4 +192,23 @@ export class CloudPoints {
|
|
|
92
192
|
const yVariance = variance(yValues, avgY);
|
|
93
193
|
return new NumberNode(+(covXY / Math.sqrt(xVariance * yVariance)).toFixed(2));
|
|
94
194
|
}
|
|
195
|
+
getEvolutionType() {
|
|
196
|
+
const pointsSortedByXIncreasing = this.points.toSorted((p1, p2) => p1.x.evaluate() - p2.x.evaluate());
|
|
197
|
+
const pointsSortedByYIncreasing = this.points.toSorted((p1, p2) => p1.y.evaluate() - p2.y.evaluate());
|
|
198
|
+
const isIncreasing = pointsSortedByXIncreasing.every((point, i) => point === pointsSortedByYIncreasing[i]);
|
|
199
|
+
if (isIncreasing) {
|
|
200
|
+
return "increasing";
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const isDecreasing = pointsSortedByXIncreasing
|
|
204
|
+
.toReversed()
|
|
205
|
+
.every((point, i) => point === pointsSortedByYIncreasing[i]);
|
|
206
|
+
if (isDecreasing) {
|
|
207
|
+
return "decreasing";
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
return "scatter";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
95
214
|
}
|
|
@@ -46,5 +46,6 @@ export declare class Line {
|
|
|
46
46
|
toTexNoLeftRight(): string;
|
|
47
47
|
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, color, label, }?: ToGGBCommandsProps): string[];
|
|
48
48
|
intersect(line: Line, intersectName?: string): Point;
|
|
49
|
+
translate(x: AlgebraicNode | number, y: AlgebraicNode | number): Line;
|
|
49
50
|
}
|
|
50
51
|
//# sourceMappingURL=line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAG1F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAS,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmB3E,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AACF,8BAAsB,eAAe;IACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;IAO3B,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,eAAe;IAOnD,MAAM,CAAC,WAAW,CAAC,OAAO,EA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|
|
60
60
|
unformatedName;
|
|
61
61
|
ggbName;
|
|
62
|
+
//!TODO Sebastien : "_nbMaxStepsForSimplify" ne doit pas être nécessaire, à fix
|
|
62
63
|
constructor(pointA, pointB, name) {
|
|
63
64
|
this.pointA = pointA;
|
|
64
65
|
this.pointB = pointB;
|
|
@@ -71,8 +72,12 @@ export class Line {
|
|
|
71
72
|
this.b = undefined;
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
|
-
this.a = new FractionNode(new SubstractNode(this.pointB.y, this.pointA.y), new SubstractNode(this.pointB.x, this.pointA.x)).simplify(
|
|
75
|
-
|
|
75
|
+
this.a = new FractionNode(new SubstractNode(this.pointB.y, this.pointA.y), new SubstractNode(this.pointB.x, this.pointA.x)).simplify({
|
|
76
|
+
// nbMaxSteps: _nbMaxStepsForSimplify,
|
|
77
|
+
});
|
|
78
|
+
this.b = new SubstractNode(this.pointA.y, new MultiplyNode(this.a, this.pointA.x)).simplify({
|
|
79
|
+
// nbMaxSteps: _nbMaxStepsForSimplify,
|
|
80
|
+
});
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
toIdentifiers() {
|
|
@@ -244,4 +249,7 @@ export class Line {
|
|
|
244
249
|
const solve = sys.solve();
|
|
245
250
|
return new Point(intersectName ?? "I", solve.x, solve.y);
|
|
246
251
|
}
|
|
252
|
+
translate(x, y) {
|
|
253
|
+
return new Line(this.pointA.translate(x, y), this.pointB.translate(x, y));
|
|
254
|
+
}
|
|
247
255
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAoB7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE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!TODO Sebastien : "_nbMaxStepsForSimplify" ne doit pas être nécessaire, à fix
|
|
168
|
+
rotate(angle, name) {
|
|
169
|
+
//x' = cos(t)*x -sin(t)*y
|
|
170
|
+
//y' = sin(t)*x + cos(t)*y
|
|
171
|
+
const cos = Math.cos(angle);
|
|
172
|
+
const sin = Math.sin(angle);
|
|
173
|
+
return new Vector(name, substract(multiply(cos, this.x).simplify(), multiply(sin, this.y).simplify()).simplify({
|
|
174
|
+
// nbMaxSteps: _nbMaxStepsForSimplify,
|
|
175
|
+
}), add(multiply(sin, this.x).simplify(), multiply(cos, this.y).simplify()).simplify({
|
|
176
|
+
// nbMaxSteps: _nbMaxStepsForSimplify,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
167
179
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
|
|
2
|
+
import { VariableNode } from "../../tree/nodes/variables/variableNode.js";
|
|
3
|
+
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor.js";
|
|
4
|
+
export type ProgCalcOperator = "opposite" | "inverse" | "add" | "subtract" | "multiply" | "divide";
|
|
5
|
+
export interface ProgCalcOperationGenerationConfig {
|
|
6
|
+
operator: ProgCalcOperator;
|
|
7
|
+
createParam: () => number | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare const arrOpGenConfigDefault: ProgCalcOperationGenerationConfig[];
|
|
10
|
+
export declare abstract class ProgCalcOperationConstructor {
|
|
11
|
+
static randomFromOpGenConfig(opGenConfig: ProgCalcOperationGenerationConfig): ProgCalcOperation;
|
|
12
|
+
static fromIdentifiers(opIds: ProgCalcOperationIdentifiers): ProgCalcOperation;
|
|
13
|
+
}
|
|
14
|
+
export type ProgCalcOperationIdentifiers = {
|
|
15
|
+
operator: ProgCalcOperator;
|
|
16
|
+
param?: NodeIdentifiers;
|
|
17
|
+
};
|
|
18
|
+
export declare class ProgCalcOperation {
|
|
19
|
+
operationIds: ProgCalcOperationIdentifiers;
|
|
20
|
+
strFrench: string;
|
|
21
|
+
func: (node: AlgebraicNode) => AlgebraicNode;
|
|
22
|
+
inverseOperationIds: ProgCalcOperationIdentifiers;
|
|
23
|
+
constructor(operationIds: ProgCalcOperationIdentifiers, strFrench: string, func: (node: AlgebraicNode) => AlgebraicNode, inverseOperationIds: ProgCalcOperationIdentifiers);
|
|
24
|
+
getInverseOperation(): ProgCalcOperation;
|
|
25
|
+
toIdentifiers(): ProgCalcOperationIdentifiers;
|
|
26
|
+
}
|
|
27
|
+
export type ProgCalcIdentifiers = {
|
|
28
|
+
operationIds: ProgCalcOperationIdentifiers[];
|
|
29
|
+
};
|
|
30
|
+
export declare abstract class ProgCalcConstructor {
|
|
31
|
+
static random(nbSteps: number, isSingleUseOperators?: boolean, arrAvailableOpGenConfig?: ProgCalcOperationGenerationConfig[]): ProgCalc;
|
|
32
|
+
static randomWithMandatory(nbSteps: number, isSingleUseOperators: boolean, arrOpGenConfigMandatory: ProgCalcOperationGenerationConfig[], arrOpGenConfigAll: ProgCalcOperationGenerationConfig[]): ProgCalc;
|
|
33
|
+
static exampleRandomAffine(nbSteps?: number, isSingleUseOperators?: boolean): ProgCalc;
|
|
34
|
+
static randomMental(nbSteps: number, nodeStartingNumber: AlgebraicNode, nbDigits?: number, isSingleUseOperators?: boolean): ProgCalc;
|
|
35
|
+
static fromIdentifiers(pcIds: ProgCalcIdentifiers): ProgCalc;
|
|
36
|
+
}
|
|
37
|
+
export declare class ProgCalc {
|
|
38
|
+
operations: ProgCalcOperation[];
|
|
39
|
+
constructor(arrOperation: ProgCalcOperation[]);
|
|
40
|
+
apply(node: AlgebraicNode): AlgebraicNode;
|
|
41
|
+
getArrOfFrenchStrings(): string[];
|
|
42
|
+
getInverseProgCalc(): ProgCalc | undefined;
|
|
43
|
+
toTree(nodeVariable: VariableNode): AlgebraicNode;
|
|
44
|
+
toIdentifiers(): ProgCalcIdentifiers;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=progCalc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E,4BAA4B,EAAE,CAAC;CAC9C,CAAC;AAEF,8BAAsB,mBAAmB;IACvC,MAAM,CAAC,MAAM,CACX,OAAO,EAAE,MAAM,EACf,oBAAoB,GAAE,OAAc,EACpC,uBAAuB,GAAE,iCAAiC,EAA0B;IAatF,MAAM,CAAC,mBAAmB,CACxB,OAAO,EAAE,MAAM,EACf,oBAAoB,EAAE,OAAO,EAC7B,uBAAuB,EAAE,iCAAiC,EAAE,EAC5D,iBAAiB,EAAE,iCAAiC,EAAE;IAyBxD,MAAM,CAAC,mBAAmB,CACxB,OAAO,GAAE,MAAU,EACnB,oBAAoB,GAAE,OAAc;IA6CtC,MAAM,CAAC,YAAY,CACjB,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,aAAa,EACjC,QAAQ,GAAE,MAAU,EACpB,oBAAoB,GAAE,OAAc;IA2EtC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,mBAAmB;CAMlD;AAED,qBAAa,QAAQ;IACnB,UAAU,EAAE,iBAAiB,EAAE,CAAC;gBAEpB,YAAY,EAAE,iBAAiB,EAAE;IAI7C,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa;IASzC,qBAAqB,IAAI,MAAM,EAAE;IAIjC,kBAAkB,IAAI,QAAQ,GAAG,SAAS;IAO1C,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,aAAa;IAIjD,aAAa,IAAI,mBAAmB;CAOrC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { opposite } from "../../tree/nodes/functions/oppositeNode.js";
|
|
2
|
+
import { add } from "../../tree/nodes/operators/addNode.js";
|
|
3
|
+
import { frac } from "../../tree/nodes/operators/fractionNode.js";
|
|
4
|
+
import { multiply } from "../../tree/nodes/operators/multiplyNode.js";
|
|
5
|
+
import { substract } from "../../tree/nodes/operators/substractNode.js";
|
|
6
|
+
import { random, randomMany } from "../../utils/alea/random.js";
|
|
7
|
+
import { randint } from "../utils/random/randint.js";
|
|
8
|
+
import { isInt } from "../../utils/isInt.js";
|
|
9
|
+
import { NodeConstructor, } from "../../tree/nodes/nodeConstructor.js";
|
|
10
|
+
import { shuffle } from "../../utils/alea/shuffle.js";
|
|
11
|
+
export const arrOpGenConfigDefault = [
|
|
12
|
+
{
|
|
13
|
+
operator: "opposite",
|
|
14
|
+
createParam: () => undefined,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
operator: "inverse",
|
|
18
|
+
createParam: () => undefined,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
operator: "add",
|
|
22
|
+
createParam: () => randint(-10, 11, []),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
operator: "subtract",
|
|
26
|
+
createParam: () => randint(-10, 11, []),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
operator: "multiply",
|
|
30
|
+
createParam: () => randint(-10, 11, [0]),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
operator: "divide",
|
|
34
|
+
createParam: () => randint(-10, 11, [0]),
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
export class ProgCalcOperationConstructor {
|
|
38
|
+
static randomFromOpGenConfig(opGenConfig) {
|
|
39
|
+
const opIds = {
|
|
40
|
+
operator: opGenConfig.operator,
|
|
41
|
+
param: opGenConfig.createParam()?.toTree().toIdentifiers(),
|
|
42
|
+
};
|
|
43
|
+
return ProgCalcOperationConstructor.fromIdentifiers(opIds);
|
|
44
|
+
}
|
|
45
|
+
static fromIdentifiers(opIds) {
|
|
46
|
+
switch (opIds.operator) {
|
|
47
|
+
case "opposite":
|
|
48
|
+
return new ProgCalcOperation(opIds, `Prendre l'opposé`, (node) => opposite(node), { operator: "opposite" });
|
|
49
|
+
case "inverse":
|
|
50
|
+
return new ProgCalcOperation(opIds, `Prendre l'inverse`, (node) => frac(1, node), { operator: "inverse" });
|
|
51
|
+
case "add": {
|
|
52
|
+
const nodeParam = NodeConstructor.fromIdentifiers(opIds.param);
|
|
53
|
+
return new ProgCalcOperation(opIds, `Ajouter $ ${nodeParam.toTex()} $`, (nodeX) => add(nodeX, nodeParam), { operator: "subtract", param: opIds.param });
|
|
54
|
+
}
|
|
55
|
+
case "subtract": {
|
|
56
|
+
const nodeParam = NodeConstructor.fromIdentifiers(opIds.param);
|
|
57
|
+
const strFrench = random([
|
|
58
|
+
`Soustraire $ ${nodeParam.toTex()} $`,
|
|
59
|
+
`Oter $ ${nodeParam.toTex()} $`,
|
|
60
|
+
`Enlever $ ${nodeParam.toTex()} $`,
|
|
61
|
+
]);
|
|
62
|
+
return new ProgCalcOperation(opIds, strFrench, (nodeX) => substract(nodeX, nodeParam), { operator: "add", param: opIds.param });
|
|
63
|
+
}
|
|
64
|
+
case "multiply": {
|
|
65
|
+
const nodeParam = NodeConstructor.fromIdentifiers(opIds.param);
|
|
66
|
+
return new ProgCalcOperation(opIds, `Multiplier par $ ${nodeParam.toTex()} $`, (nodeX) => multiply(nodeX, nodeParam), { operator: "divide", param: opIds.param });
|
|
67
|
+
}
|
|
68
|
+
case "divide": {
|
|
69
|
+
const nodeParam = NodeConstructor.fromIdentifiers(opIds.param);
|
|
70
|
+
return new ProgCalcOperation(opIds, `Diviser par $ ${nodeParam.toTex()} $`, (nodeX) => frac(nodeX, nodeParam), { operator: "multiply", param: opIds.param });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export class ProgCalcOperation {
|
|
76
|
+
operationIds;
|
|
77
|
+
strFrench;
|
|
78
|
+
func;
|
|
79
|
+
inverseOperationIds;
|
|
80
|
+
constructor(operationIds, strFrench, func, inverseOperationIds) {
|
|
81
|
+
this.operationIds = operationIds;
|
|
82
|
+
this.strFrench = strFrench;
|
|
83
|
+
this.func = func;
|
|
84
|
+
this.inverseOperationIds = inverseOperationIds;
|
|
85
|
+
}
|
|
86
|
+
getInverseOperation() {
|
|
87
|
+
return ProgCalcOperationConstructor.fromIdentifiers(this.inverseOperationIds);
|
|
88
|
+
}
|
|
89
|
+
toIdentifiers() {
|
|
90
|
+
return this.operationIds;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export class ProgCalcConstructor {
|
|
94
|
+
static random(nbSteps, isSingleUseOperators = true, arrAvailableOpGenConfig = arrOpGenConfigDefault) {
|
|
95
|
+
const arrOpGenConfig = isSingleUseOperators
|
|
96
|
+
? randomMany(arrAvailableOpGenConfig, nbSteps)
|
|
97
|
+
: [...Array(nbSteps).keys()].map(() => random(arrAvailableOpGenConfig));
|
|
98
|
+
return new ProgCalc(shuffle(arrOpGenConfig).map((opGenConfig) => ProgCalcOperationConstructor.randomFromOpGenConfig(opGenConfig)));
|
|
99
|
+
}
|
|
100
|
+
static randomWithMandatory(nbSteps, isSingleUseOperators, arrOpGenConfigMandatory, arrOpGenConfigAll) {
|
|
101
|
+
const nbFiller = nbSteps - arrOpGenConfigMandatory.length;
|
|
102
|
+
const arrOpGenConfigFiller = nbFiller > 0 && isSingleUseOperators
|
|
103
|
+
? randomMany(arrOpGenConfigAll.filter((opGenConfig) => !arrOpGenConfigMandatory.includes(opGenConfig)), nbFiller)
|
|
104
|
+
: [...Array(nbFiller).keys()].map(() => random(arrOpGenConfigAll));
|
|
105
|
+
const arrOpGenConfig = [
|
|
106
|
+
...arrOpGenConfigMandatory,
|
|
107
|
+
...arrOpGenConfigFiller,
|
|
108
|
+
];
|
|
109
|
+
return new ProgCalc(shuffle(arrOpGenConfig).map((opGenConfig) => ProgCalcOperationConstructor.randomFromOpGenConfig(opGenConfig)));
|
|
110
|
+
}
|
|
111
|
+
static exampleRandomAffine(nbSteps = 2, isSingleUseOperators = true) {
|
|
112
|
+
const arrOpGenAddsub = [
|
|
113
|
+
{
|
|
114
|
+
operator: "add",
|
|
115
|
+
createParam: () => randint(-10, 11, [0]),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
operator: "subtract",
|
|
119
|
+
createParam: () => randint(-10, 11, [0]),
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
const arrOpGenMuldiv = [
|
|
123
|
+
{
|
|
124
|
+
operator: "opposite",
|
|
125
|
+
createParam: () => undefined,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
operator: "multiply",
|
|
129
|
+
createParam: () => randint(-10, 11, [0, 1]),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
operator: "divide",
|
|
133
|
+
createParam: () => randint(-10, 11, [0, 1]),
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
const arrOpGenConfigAll = [...arrOpGenAddsub, ...arrOpGenMuldiv];
|
|
137
|
+
//ensure that there is at least 1 addsub and 1 muldiv operation
|
|
138
|
+
const opGenConfigAddsub = random(arrOpGenAddsub);
|
|
139
|
+
const opGenConfigMuldiv = random(arrOpGenMuldiv);
|
|
140
|
+
const arrOpGenConfigMandatory = shuffle([
|
|
141
|
+
opGenConfigAddsub,
|
|
142
|
+
opGenConfigMuldiv,
|
|
143
|
+
]);
|
|
144
|
+
return ProgCalcConstructor.randomWithMandatory(nbSteps, isSingleUseOperators, arrOpGenConfigMandatory, arrOpGenConfigAll);
|
|
145
|
+
}
|
|
146
|
+
static randomMental(nbSteps, nodeStartingNumber, nbDigits = 0, isSingleUseOperators = true) {
|
|
147
|
+
//we ensure that intermediate operations will yield a result with nbDigits
|
|
148
|
+
const arrOpGenAll = [
|
|
149
|
+
{
|
|
150
|
+
operator: "opposite",
|
|
151
|
+
createParam: () => undefined,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
operator: "inverse",
|
|
155
|
+
createParam: () => undefined,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
operator: "add",
|
|
159
|
+
createParam: () => randint(-10, 11, []),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
operator: "subtract",
|
|
163
|
+
createParam: () => randint(-10, 11, []),
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
operator: "multiply",
|
|
167
|
+
createParam: () => randint(-10, 11, [0]),
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
operator: "divide",
|
|
171
|
+
createParam: () => randint(-10, 11, [0]),
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
const arrOperation = [];
|
|
175
|
+
let nodeCurrent = nodeStartingNumber;
|
|
176
|
+
let arrAvailableOpGenConfigCurrent = arrOpGenAll;
|
|
177
|
+
for (let i = 0; i < nbSteps; i++) {
|
|
178
|
+
let isOperationValid = false;
|
|
179
|
+
let operation;
|
|
180
|
+
do {
|
|
181
|
+
const opGenConfig = random(arrAvailableOpGenConfigCurrent.filter((opGenConfig) => {
|
|
182
|
+
const isZero = nodeCurrent.evaluate() === 0;
|
|
183
|
+
return !(opGenConfig.operator === "inverse" && isZero);
|
|
184
|
+
}));
|
|
185
|
+
operation =
|
|
186
|
+
ProgCalcOperationConstructor.randomFromOpGenConfig(opGenConfig);
|
|
187
|
+
const nodeResult = operation.func(nodeCurrent);
|
|
188
|
+
const numberResult = nodeResult.evaluate();
|
|
189
|
+
const isValidResult = isInt(numberResult * Math.pow(10, nbDigits));
|
|
190
|
+
if (isValidResult) {
|
|
191
|
+
isOperationValid = true;
|
|
192
|
+
nodeCurrent = nodeResult;
|
|
193
|
+
const operatorUsed = operation.operationIds.operator;
|
|
194
|
+
if (isSingleUseOperators) {
|
|
195
|
+
arrAvailableOpGenConfigCurrent =
|
|
196
|
+
arrAvailableOpGenConfigCurrent.filter((opGenConfig) => opGenConfig.operator !== operatorUsed);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} while (!isOperationValid);
|
|
200
|
+
arrOperation.push(operation);
|
|
201
|
+
}
|
|
202
|
+
return new ProgCalc(arrOperation);
|
|
203
|
+
}
|
|
204
|
+
static fromIdentifiers(pcIds) {
|
|
205
|
+
const arrOperation = pcIds.operationIds.map(ProgCalcOperationConstructor.fromIdentifiers);
|
|
206
|
+
return new ProgCalc(arrOperation);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export class ProgCalc {
|
|
210
|
+
operations;
|
|
211
|
+
constructor(arrOperation) {
|
|
212
|
+
this.operations = arrOperation;
|
|
213
|
+
}
|
|
214
|
+
apply(node) {
|
|
215
|
+
let nodeCurrent = node;
|
|
216
|
+
for (let i = 0; i < this.operations.length; i++) {
|
|
217
|
+
const operation = this.operations[i];
|
|
218
|
+
nodeCurrent = operation.func(nodeCurrent);
|
|
219
|
+
}
|
|
220
|
+
return nodeCurrent;
|
|
221
|
+
}
|
|
222
|
+
getArrOfFrenchStrings() {
|
|
223
|
+
return this.operations.map((op) => op.strFrench);
|
|
224
|
+
}
|
|
225
|
+
getInverseProgCalc() {
|
|
226
|
+
const arrOpInverse = this.operations
|
|
227
|
+
.reverse()
|
|
228
|
+
.map((op) => op.getInverseOperation());
|
|
229
|
+
return new ProgCalc(arrOpInverse);
|
|
230
|
+
}
|
|
231
|
+
toTree(nodeVariable) {
|
|
232
|
+
return this.apply(nodeVariable);
|
|
233
|
+
}
|
|
234
|
+
toIdentifiers() {
|
|
235
|
+
return {
|
|
236
|
+
operationIds: this.operations.map((operation) => operation.toIdentifiers()),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../../tree/nodes/algebraicNode.js";
|
|
2
|
+
import { EqualNode } from "../../../tree/nodes/equations/equalNode.js";
|
|
3
|
+
import { InequationNode } from "../../../tree/nodes/inequations/inequationNode.js";
|
|
4
|
+
export type RandomNodeType = "I" | "RI" | "H" | "RH" | "F" | CustomRandomNodeType;
|
|
5
|
+
export type CustomRandomNodeType = {
|
|
6
|
+
custom: () => AlgebraicNode;
|
|
7
|
+
};
|
|
8
|
+
export declare function randomNodeWithType(rvType: RandomNodeType): AlgebraicNode | import("../../../tree/nodes/numbers/constantNode.js").ConstantNode | import("../../../tree/nodes/numbers/numberNode.js").NumberNode;
|
|
9
|
+
export declare function realize(varNameToGenType: Record<string, RandomNodeType>): (str: string) => string;
|
|
10
|
+
export declare function realizeLatex(varNameToGenType: Record<string, RandomNodeType>): (str: string) => AlgebraicNode | EqualNode | InequationNode;
|
|
11
|
+
export declare function realizeAlgebraic(varNameToGenType: Record<string, RandomNodeType>): (str: string) => AlgebraicNode | EqualNode | InequationNode;
|
|
12
|
+
//# sourceMappingURL=realize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realize.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/latex/realize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAKhF,MAAM,MAAM,cAAc,GACtB,GAAG,GACH,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,GAAG,GACH,oBAAoB,CAAC;AACzB,MAAM,MAAM,oBAAoB,GAAG;IAAE,MAAM,EAAE,MAAM,aAAa,CAAA;CAAE,CAAC;AAEnE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,uJAiBxD;AAED,wBAAgB,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IACrD,KAAK,MAAM,KAAG,MAAM,CAStC;AAED,wBAAgB,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IAC1D,KAAK,MAAM,KAAG,aAAa,GAAG,SAAS,GAAG,cAAc,CAG1E;AAED,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IAE/B,KAAK,MAAM,KAAG,aAAa,GAAG,SAAS,GAAG,cAAc,CAG1E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { parseAlgebraic, parseLatex } from "../../../tree/parsers/latexParser.js";
|
|
2
|
+
import { randfloat } from "../random/randfloat.js";
|
|
3
|
+
import { randint } from "../random/randint.js";
|
|
4
|
+
export function randomNodeWithType(rvType) {
|
|
5
|
+
if (typeof rvType !== "string") {
|
|
6
|
+
return rvType.custom();
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
switch (rvType) {
|
|
10
|
+
case "I":
|
|
11
|
+
return randint(1, 10).toTree();
|
|
12
|
+
case "RI":
|
|
13
|
+
return randint(-9, 10, [0]).toTree();
|
|
14
|
+
case "H":
|
|
15
|
+
return randint(1, 100).toTree();
|
|
16
|
+
case "RH":
|
|
17
|
+
return randint(-99, 100, [0]).toTree();
|
|
18
|
+
case "F":
|
|
19
|
+
return randfloat(0, 1, 2, [0]).toTree();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function realize(varNameToGenType) {
|
|
24
|
+
return function (str) {
|
|
25
|
+
let outStr = str;
|
|
26
|
+
Object.keys(varNameToGenType).forEach((key) => {
|
|
27
|
+
const randomNodeType = varNameToGenType[key];
|
|
28
|
+
const tex = `{${randomNodeWithType(randomNodeType).toTex()}}`;
|
|
29
|
+
outStr = outStr.replaceAll(key, tex);
|
|
30
|
+
});
|
|
31
|
+
return outStr;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function realizeLatex(varNameToGenType) {
|
|
35
|
+
return function (str) {
|
|
36
|
+
return parseLatex(realize(varNameToGenType)(str));
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function realizeAlgebraic(varNameToGenType) {
|
|
40
|
+
return function (str) {
|
|
41
|
+
return parseAlgebraic(realize(varNameToGenType)(str));
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -19,6 +19,8 @@ export declare class Molecule {
|
|
|
19
19
|
iupact?: string;
|
|
20
20
|
type?: string;
|
|
21
21
|
constructor(name: string, formula: string, weight: number, atoms: AtomShortcut[], isOrganic: boolean, state: "solid" | "liquid" | "gas" | "aqueous", iupact?: string, type?: string);
|
|
22
|
+
static electronegativityOrder: Record<string, number>;
|
|
23
|
+
getRawFormula(): string;
|
|
22
24
|
}
|
|
23
25
|
export declare const molecules: Molecule[];
|
|
24
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"molecule.d.ts","sourceRoot":"","sources":["../../../../src/pc/constants/molecularChemistry/molecule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAU,MAAM,YAAY,CAAC;AAE3C,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AACD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAYF,qBAAa,QAAQ;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;gBAGZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,EAAE,EACrB,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,EAC7C,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"molecule.d.ts","sourceRoot":"","sources":["../../../../src/pc/constants/molecularChemistry/molecule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAU,MAAM,YAAY,CAAC;AAE3C,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AACD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAYF,qBAAa,QAAQ;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;gBAGZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,EAAE,EACrB,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,EAC7C,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM;IAkBf,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BhD;IAEL,aAAa;CAmCd;AAED,eAAO,MAAM,SAAS,YA43CrB,CAAC"}
|
|
@@ -35,6 +35,58 @@ export class Molecule {
|
|
|
35
35
|
this.iupact = iupact;
|
|
36
36
|
this.type = type;
|
|
37
37
|
}
|
|
38
|
+
static electronegativityOrder = (() => {
|
|
39
|
+
const arrayOfAtoms = `Rn Xe Kr Ar Ne He
|
|
40
|
+
Fr Cs Rb K Na Li
|
|
41
|
+
Ra Ba Sr Ca Mg Be
|
|
42
|
+
Lr Ac Lu La Y Sc
|
|
43
|
+
Rf Hf Zr Ti
|
|
44
|
+
Db Ta Nb V
|
|
45
|
+
Sg W Mo Cr
|
|
46
|
+
Bh Re Tc Mn
|
|
47
|
+
Hs Os Ru Fe
|
|
48
|
+
Mt Ir Rh Co
|
|
49
|
+
Ds Pt Pd Ni
|
|
50
|
+
Rg Au Ag Cu
|
|
51
|
+
Hg Cd Zn
|
|
52
|
+
Tl In Ga Al B
|
|
53
|
+
Pb Sn Ge Si C
|
|
54
|
+
Bi Sb As P N H
|
|
55
|
+
Po Te Se S O
|
|
56
|
+
At I Br Cl F`
|
|
57
|
+
.replace(/\s/g, ",")
|
|
58
|
+
.split(",");
|
|
59
|
+
return Object.fromEntries(arrayOfAtoms.map((atom, i) => {
|
|
60
|
+
return [atom, i];
|
|
61
|
+
}));
|
|
62
|
+
})();
|
|
63
|
+
getRawFormula() {
|
|
64
|
+
const symboleForAtomsData = Object.fromEntries(this.atoms.map((atomsData) => [atomsData.atom.symbole, atomsData]));
|
|
65
|
+
const symbolsFirst = this.isOrganic ? ["C", "H", "O"] : [];
|
|
66
|
+
const arrayFirst = symbolsFirst
|
|
67
|
+
.map((symbole) => symboleForAtomsData[symbole])
|
|
68
|
+
.filter((atomsData) => !!atomsData);
|
|
69
|
+
const arrayRest = (() => {
|
|
70
|
+
const symboleForAtomsDataCopy = Object.assign(symboleForAtomsData, {});
|
|
71
|
+
symbolsFirst.forEach((symbole) => {
|
|
72
|
+
delete symboleForAtomsDataCopy[symbole];
|
|
73
|
+
});
|
|
74
|
+
return Object.values(symboleForAtomsDataCopy);
|
|
75
|
+
})().toSorted(({ atom: atom1 }, { atom: atom2 }) => Molecule.electronegativityOrder[atom1.symbole] -
|
|
76
|
+
Molecule.electronegativityOrder[atom2.symbole]);
|
|
77
|
+
const sortedArrayAtomsData = [...arrayFirst, ...arrayRest];
|
|
78
|
+
let rawFormula = ``;
|
|
79
|
+
for (let i = 0; i < sortedArrayAtomsData.length; i++) {
|
|
80
|
+
const atomData = sortedArrayAtomsData[i];
|
|
81
|
+
if (atomData.count > 1) {
|
|
82
|
+
rawFormula += `${atomData.atom.symbole}_{${atomData.count.frenchify()}}`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
rawFormula += `${atomData.atom.symbole}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return rawFormula;
|
|
89
|
+
}
|
|
38
90
|
}
|
|
39
91
|
export const molecules = [
|
|
40
92
|
new Molecule("Dihydrogène", "H_2", 2.016, [{ name: "H", count: 2 }], false, "gas"),
|