math-exercises 1.3.67 → 1.3.69

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.
@@ -1 +1 @@
1
- {"version":3,"file":"geometricSequence.d.ts","sourceRoot":"","sources":["../../../src/math/sequences/geometricSequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAOvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIvD,8BAAsB,4BAA4B;IAChD,MAAM,CAAC,MAAM,CAAC,UAAU,GAAE,UAA+B;IAkBzD,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;CAmB/C;AAED,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;gBAEH,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK7C,QAAQ;IAMR,MAAM;CAGP"}
1
+ {"version":3,"file":"geometricSequence.d.ts","sourceRoot":"","sources":["../../../src/math/sequences/geometricSequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAOvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIvD,8BAAsB,4BAA4B;IAChD,MAAM,CAAC,MAAM,CAAC,UAAU,GAAE,UAA+B;IAkBzD,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;CAsB/C;AAED,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;gBAEH,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK7C,QAAQ;IAMR,MAAM;CAGP"}
@@ -35,7 +35,10 @@ class GeometricSequenceConstructor {
35
35
  const type = reasonType ?? (0, random_1.random)([nombre_1.NumberType.Decimal, nombre_1.NumberType.Integer, nombre_1.NumberType.Rational]);
36
36
  switch (type) {
37
37
  case nombre_1.NumberType.Decimal:
38
- reason = (0, coinFlip_1.coinFlip)() ? decimal_1.DecimalConstructor.random(-1, 1) : decimal_1.DecimalConstructor.random(1, 10);
38
+ const precision = (0, randint_1.randint)(1, 4);
39
+ reason = (0, coinFlip_1.coinFlip)()
40
+ ? decimal_1.DecimalConstructor.fromParts((0, coinFlip_1.coinFlip)() ? '0' : '-0', decimal_1.DecimalConstructor.randomFracPart(precision))
41
+ : decimal_1.DecimalConstructor.random(1, 10);
39
42
  break;
40
43
  case nombre_1.NumberType.Integer:
41
44
  reason = new integer_1.Integer((0, randint_1.randint)(2, 10, [0, 1]));
@@ -56,16 +59,16 @@ class GeometricSequence {
56
59
  this.reason = reason;
57
60
  }
58
61
  getLimit() {
59
- if (this.reason.value < -1)
62
+ if (this.reason.value <= -1)
60
63
  return null;
61
- if (this.reason.value === 1 || this.reason.value === -1)
64
+ if (this.reason.value === 1)
62
65
  return this.firstTerm + '';
63
66
  if (this.reason.value > 1)
64
67
  return this.firstTerm.value > 0 ? '+\\infty' : '-\\infty';
65
68
  return '0';
66
69
  }
67
70
  toTree() {
68
- return new multiplyNode_1.MultiplyNode(this.firstTerm.toTree(), new powerNode_1.PowerNode(this.reason.toTree(), new variableNode_1.VariableNode('n')));
71
+ return new multiplyNode_1.MultiplyNode(this.firstTerm.toTree(), new powerNode_1.PowerNode(this.reason.toTree(), new variableNode_1.VariableNode('n')), true);
69
72
  }
70
73
  }
71
74
  exports.GeometricSequence = GeometricSequence;
@@ -1,7 +1,8 @@
1
1
  import { Node } from '../node';
2
2
  import { OperatorNode } from './operatorNode';
3
3
  export declare class MultiplyNode extends OperatorNode implements Node {
4
- constructor(leftChild: Node, rightChild: Node);
4
+ forceTimesSign?: boolean;
5
+ constructor(leftChild: Node, rightChild: Node, forceTimesSign?: boolean);
5
6
  toMathString(): string;
6
7
  toTex(): string;
7
8
  toMathjs(): any;
@@ -1 +1 @@
1
- {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI;IAY7C,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAoCf,QAAQ;CAGT"}
1
+ {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;IAC5D,cAAc,CAAC,EAAE,OAAO,CAAC;gBACb,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO;IAavE,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAoCf,QAAQ;CAGT"}
@@ -6,7 +6,7 @@ const functionNode_1 = require("../functions/functionNode");
6
6
  const node_1 = require("../node");
7
7
  const operatorNode_1 = require("./operatorNode");
8
8
  class MultiplyNode extends operatorNode_1.OperatorNode {
9
- constructor(leftChild, rightChild) {
9
+ constructor(leftChild, rightChild, forceTimesSign) {
10
10
  let [left, right] = [leftChild, rightChild];
11
11
  const shouldSwitch = (rightChild.type === node_1.NodeType.function && rightChild.id === functionNode_1.FunctionsIds.opposite) ||
12
12
  (leftChild.type === node_1.NodeType.constant && rightChild.type === node_1.NodeType.number);
@@ -14,6 +14,7 @@ class MultiplyNode extends operatorNode_1.OperatorNode {
14
14
  [left, right] = [rightChild, leftChild];
15
15
  }
16
16
  super(operatorNode_1.OperatorIds.multiply, left, right, true, '\\times');
17
+ this.forceTimesSign = forceTimesSign;
17
18
  }
18
19
  toMathString() {
19
20
  return `(${this.leftChild.toMathString()})*(${this.rightChild.toMathString()})`;
@@ -38,10 +39,10 @@ class MultiplyNode extends operatorNode_1.OperatorNode {
38
39
  if (needBrackets)
39
40
  rightTex = `(${rightTex})`;
40
41
  // permet de gérer le cas 3*2^x par ex
41
- let showTimesSign = !isNaN(+rightTex[0]) || this.rightChild.type === node_1.NodeType.number;
42
+ let showTimesSign = this.forceTimesSign || !isNaN(+rightTex[0]) || this.rightChild.type === node_1.NodeType.number;
42
43
  if (this.rightChild.type === node_1.NodeType.operator) {
43
44
  const operatorRightChild = this.rightChild;
44
- showTimesSign ||= [operatorNode_1.OperatorIds.fraction, operatorNode_1.OperatorIds.power].includes(operatorRightChild.id);
45
+ showTimesSign ||= [operatorNode_1.OperatorIds.fraction].includes(operatorRightChild.id);
45
46
  }
46
47
  const nextIsLetter = rightTex[0].toLowerCase() !== rightTex[0].toUpperCase();
47
48
  return `${leftTex}${showTimesSign ? `\\times${nextIsLetter ? ' ' : ''}` : ''}${rightTex}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.67",
3
+ "version": "1.3.69",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [