@cortex-js/compute-engine 0.56.0 → 0.58.0

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 (259) hide show
  1. package/dist/compile.esm.js +1137 -92
  2. package/dist/compile.min.esm.js +261 -61
  3. package/dist/compile.min.umd.cjs +262 -62
  4. package/dist/compile.umd.cjs +1137 -92
  5. package/dist/compute-engine.esm.js +1751 -176
  6. package/dist/compute-engine.min.esm.js +273 -73
  7. package/dist/compute-engine.min.umd.cjs +272 -72
  8. package/dist/compute-engine.umd.cjs +1751 -176
  9. package/dist/core.esm.js +1750 -175
  10. package/dist/core.min.esm.js +271 -71
  11. package/dist/core.min.umd.cjs +271 -71
  12. package/dist/core.umd.cjs +1750 -175
  13. package/dist/interval.esm.js +357 -28
  14. package/dist/interval.min.esm.js +6 -6
  15. package/dist/interval.min.umd.cjs +6 -6
  16. package/dist/interval.umd.cjs +357 -28
  17. package/dist/latex-syntax.esm.js +398 -28
  18. package/dist/latex-syntax.min.esm.js +6 -6
  19. package/dist/latex-syntax.min.umd.cjs +6 -6
  20. package/dist/latex-syntax.umd.cjs +398 -28
  21. package/dist/math-json.esm.js +2 -2
  22. package/dist/math-json.min.esm.js +2 -2
  23. package/dist/math-json.min.umd.cjs +2 -2
  24. package/dist/math-json.umd.cjs +2 -2
  25. package/dist/numerics.esm.js +38 -3
  26. package/dist/numerics.min.esm.js +3 -3
  27. package/dist/numerics.min.umd.cjs +4 -4
  28. package/dist/numerics.umd.cjs +38 -3
  29. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  30. package/dist/types/big-decimal/index.d.ts +1 -1
  31. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  32. package/dist/types/big-decimal/utils.d.ts +1 -1
  33. package/dist/types/common/ansi-codes.d.ts +1 -1
  34. package/dist/types/common/configuration-change.d.ts +1 -1
  35. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  36. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  37. package/dist/types/common/interruptible.d.ts +1 -1
  38. package/dist/types/common/one-of.d.ts +1 -1
  39. package/dist/types/common/signals.d.ts +1 -1
  40. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  41. package/dist/types/common/type/boxed-type.d.ts +1 -1
  42. package/dist/types/common/type/lexer.d.ts +1 -1
  43. package/dist/types/common/type/parse.d.ts +1 -1
  44. package/dist/types/common/type/parser.d.ts +1 -1
  45. package/dist/types/common/type/primitive.d.ts +1 -1
  46. package/dist/types/common/type/reduce.d.ts +1 -1
  47. package/dist/types/common/type/serialize.d.ts +1 -1
  48. package/dist/types/common/type/subtype.d.ts +1 -1
  49. package/dist/types/common/type/type-builder.d.ts +1 -1
  50. package/dist/types/common/type/types.d.ts +1 -1
  51. package/dist/types/common/type/utils.d.ts +1 -1
  52. package/dist/types/common/utils.d.ts +1 -1
  53. package/dist/types/compile.d.ts +1 -1
  54. package/dist/types/compute-engine/assume.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +8 -1
  56. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +7 -1
  66. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +22 -10
  82. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  99. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  103. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  104. package/dist/types/compute-engine/compilation/base-compiler.d.ts +62 -6
  105. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  106. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  107. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  108. package/dist/types/compute-engine/compilation/gpu-target.d.ts +44 -1
  109. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  110. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  111. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  112. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  113. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  114. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  115. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  116. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  117. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  118. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  119. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  120. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  121. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  122. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  123. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  124. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  125. package/dist/types/compute-engine/engine-runtime-state.d.ts +4 -1
  126. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  127. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  128. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  132. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  133. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  134. package/dist/types/compute-engine/global-types.d.ts +1 -1
  135. package/dist/types/compute-engine/index.d.ts +18 -2
  136. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  137. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  138. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  139. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  140. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  141. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  142. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  143. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  146. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  147. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-colors.d.ts +1 -1
  148. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  149. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  150. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  151. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  152. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  153. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  154. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  155. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  156. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  157. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  158. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  159. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  168. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  170. package/dist/types/compute-engine/latex-syntax/types.d.ts +40 -1
  171. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  172. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  173. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  174. package/dist/types/compute-engine/library/collections.d.ts +5 -3
  175. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  176. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  177. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  178. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  179. package/dist/types/compute-engine/library/core.d.ts +1 -1
  180. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  181. package/dist/types/compute-engine/library/library.d.ts +1 -1
  182. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  183. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  184. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  185. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  186. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  187. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  188. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  189. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  190. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  191. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  192. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  193. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  194. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  195. package/dist/types/compute-engine/library/units.d.ts +1 -1
  196. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  197. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  198. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  199. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  200. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  201. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  202. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  203. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  204. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  205. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  206. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  207. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  208. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  209. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  210. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  211. package/dist/types/compute-engine/numerics/random.d.ts +23 -0
  212. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  213. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  214. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  215. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  216. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  217. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  218. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  219. package/dist/types/compute-engine/oeis.d.ts +1 -1
  220. package/dist/types/compute-engine/sequence.d.ts +1 -1
  221. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  222. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  223. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  224. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  225. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  226. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  227. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  228. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  229. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  230. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  231. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  232. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  233. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  234. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  235. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  236. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  237. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  238. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  239. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  240. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  241. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  242. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  243. package/dist/types/compute-engine/types-engine.d.ts +51 -1
  244. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  245. package/dist/types/compute-engine/types-expression.d.ts +69 -1
  246. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  247. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  248. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  249. package/dist/types/compute-engine/types.d.ts +1 -1
  250. package/dist/types/compute-engine.d.ts +1 -1
  251. package/dist/types/core.d.ts +1 -1
  252. package/dist/types/interval.d.ts +1 -1
  253. package/dist/types/latex-syntax.d.ts +2 -2
  254. package/dist/types/math-json/symbols.d.ts +1 -1
  255. package/dist/types/math-json/types.d.ts +1 -1
  256. package/dist/types/math-json/utils.d.ts +1 -1
  257. package/dist/types/math-json.d.ts +2 -2
  258. package/dist/types/numerics.d.ts +1 -1
  259. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** Interval 0.56.0 */
1
+ /** Interval 0.58.0 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Interval = {}));})(this, (function (exports) { 'use strict';
3
3
  var Interval = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -5218,7 +5218,42 @@ var Interval = (() => {
5218
5218
  if (b === "nothing") return a;
5219
5219
  if (isSubtype(a, b)) return b;
5220
5220
  if (isSubtype(b, a)) return a;
5221
- return superType(a, b);
5221
+ const sup = superType(a, b);
5222
+ if (LOSSY_SUPERTYPE.has(sup)) return unionTypes(a, b);
5223
+ return sup;
5224
+ }
5225
+ var LOSSY_SUPERTYPE = /* @__PURE__ */ new Set([
5226
+ "scalar",
5227
+ "value",
5228
+ "function",
5229
+ "expression",
5230
+ "collection",
5231
+ "indexed_collection",
5232
+ "list",
5233
+ "set",
5234
+ "tuple",
5235
+ "record",
5236
+ "dictionary",
5237
+ "map",
5238
+ "any"
5239
+ ]);
5240
+ function unionTypes(a, b) {
5241
+ const members = [];
5242
+ const push = (t) => {
5243
+ if (typeof t === "object" && t.kind === "union") {
5244
+ for (const m of t.types) push(m);
5245
+ return;
5246
+ }
5247
+ const key = typeof t === "string" ? t : JSON.stringify(t);
5248
+ if (!members.some(
5249
+ (m) => (typeof m === "string" ? m : JSON.stringify(m)) === key
5250
+ ))
5251
+ members.push(t);
5252
+ };
5253
+ push(a);
5254
+ push(b);
5255
+ if (members.length === 1) return members[0];
5256
+ return { kind: "union", types: members };
5222
5257
  }
5223
5258
  function narrow(...types) {
5224
5259
  if (types.length === 0) return "nothing";
@@ -6041,6 +6076,64 @@ var Interval = (() => {
6041
6076
  }
6042
6077
 
6043
6078
  // src/compute-engine/latex-syntax/dictionary/definitions-core.ts
6079
+ var COMPONENT_ACCESS_HEADS = {
6080
+ x: "First",
6081
+ y: "Second",
6082
+ z: "Third",
6083
+ real: "Real",
6084
+ re: "Real",
6085
+ imag: "Imaginary",
6086
+ im: "Imaginary",
6087
+ count: "Length",
6088
+ total: "Sum",
6089
+ max: "Max",
6090
+ min: "Min"
6091
+ };
6092
+ function memberHead(name) {
6093
+ return COMPONENT_ACCESS_HEADS[name] ?? null;
6094
+ }
6095
+ function parseComponentAccess(parser, lhs) {
6096
+ parser.skipVisualSpace();
6097
+ if (parser.match("\\operatorname")) {
6098
+ const name = parser.parseStringGroup();
6099
+ if (name === null) return null;
6100
+ const head = memberHead(name.trim());
6101
+ if (head === null) return null;
6102
+ return [head, lhs];
6103
+ }
6104
+ const tok = parser.peek;
6105
+ if (typeof tok === "string" && tok.startsWith("\\")) {
6106
+ const bare = tok.slice(1);
6107
+ const head = memberHead(bare);
6108
+ if (head !== null) {
6109
+ parser.nextToken();
6110
+ return [head, lhs];
6111
+ }
6112
+ return null;
6113
+ }
6114
+ if (typeof tok === "string" && /^[a-zA-Z]$/.test(tok)) {
6115
+ const head = memberHead(tok);
6116
+ if (head === null) return null;
6117
+ parser.nextToken();
6118
+ return [head, lhs];
6119
+ }
6120
+ return null;
6121
+ }
6122
+ function parseWhenRestriction(parser, lhs, close) {
6123
+ parser.addBoundary(close);
6124
+ parser.skipVisualSpace();
6125
+ const cond = parser.parseExpression({ minPrec: 0 });
6126
+ if (cond === null) {
6127
+ parser.removeBoundary();
6128
+ return null;
6129
+ }
6130
+ parser.skipVisualSpace();
6131
+ if (!parser.matchBoundary()) {
6132
+ parser.removeBoundary();
6133
+ return null;
6134
+ }
6135
+ return ["When", lhs, cond];
6136
+ }
6044
6137
  function parseSequence(parser, terminator, lhs, prec, sep) {
6045
6138
  if (terminator && terminator.minPrec >= prec) return null;
6046
6139
  const result = lhs ? [lhs] : ["Nothing"];
@@ -6316,15 +6409,16 @@ var Interval = (() => {
6316
6409
  precedence: ASSIGNMENT_PRECEDENCE,
6317
6410
  parse: parseAssign
6318
6411
  },
6319
- // General colon operator (type annotation, mapping notation)
6320
- // Precedence below assignment (260) so `:=` takes priority,
6321
- // and below arrows (270) so `f: A \to B` parses as `Colon(f, To(A, B))`
6412
+ // General colon operator (type annotation, mapping notation, Desmos piecewise)
6413
+ // Precedence below comparisons (245) so `cond : val` (Desmos compact piecewise)
6414
+ // parses as `Colon(cond, val)`, and below arrows (270) so
6415
+ // `f: A \to B` parses as `Colon(f, To(A, B))`.
6322
6416
  {
6323
6417
  name: "Colon",
6324
6418
  latexTrigger: ":",
6325
6419
  kind: "infix",
6326
6420
  associativity: "right",
6327
- precedence: 250,
6421
+ precedence: 240,
6328
6422
  serialize: (serializer, expr) => joinLatex([
6329
6423
  serializer.serialize(operand(expr, 1)),
6330
6424
  "\\colon",
@@ -6335,7 +6429,7 @@ var Interval = (() => {
6335
6429
  latexTrigger: "\\colon",
6336
6430
  kind: "infix",
6337
6431
  associativity: "right",
6338
- precedence: 250,
6432
+ precedence: 240,
6339
6433
  parse: "Colon"
6340
6434
  },
6341
6435
  {
@@ -6512,6 +6606,15 @@ var Interval = (() => {
6512
6606
  }
6513
6607
  },
6514
6608
  { name: "LatexTokens", serialize: serializeLatexTokens },
6609
+ // Component-access postfix: expr.member (C3)
6610
+ // The '.' trigger is consumed before the parse function is called.
6611
+ // Precedence 850 > 810 (At/indexing) so .x chains tightly.
6612
+ {
6613
+ kind: "postfix",
6614
+ precedence: 850,
6615
+ latexTrigger: ["."],
6616
+ parse: parseComponentAccess
6617
+ },
6515
6618
  {
6516
6619
  name: "At",
6517
6620
  kind: "postfix",
@@ -6532,6 +6635,29 @@ var Interval = (() => {
6532
6635
  latexTrigger: ["\\left", "\\lbrack"],
6533
6636
  parse: parseAt("\\right", "\\rbrack")
6534
6637
  },
6638
+ // When-restriction: `expr\left\{cond\right\}` → `When(expr, cond)` (D3)
6639
+ {
6640
+ name: "When",
6641
+ kind: "postfix",
6642
+ precedence: 800,
6643
+ latexTrigger: ["\\left", "\\{"],
6644
+ parse: (parser, lhs) => parseWhenRestriction(parser, lhs, ["\\right", "\\}"]),
6645
+ serialize: (serializer, expr) => {
6646
+ const e = operand(expr, 1);
6647
+ const cond = operand(expr, 2);
6648
+ if (!e || !cond) return "";
6649
+ const clauses = operator(cond) === "And" ? operands(cond) ?? [] : [cond];
6650
+ const inner = clauses.map((c) => `\\left\\{${serializer.serialize(c)}\\right\\}`).join("");
6651
+ return `${serializer.serialize(e)}${inner}`;
6652
+ }
6653
+ },
6654
+ // When-restriction: bare `expr\{cond\}` → `When(expr, cond)`
6655
+ {
6656
+ kind: "postfix",
6657
+ precedence: 800,
6658
+ latexTrigger: ["\\{"],
6659
+ parse: (parser, lhs) => parseWhenRestriction(parser, lhs, ["\\}"])
6660
+ },
6535
6661
  {
6536
6662
  kind: "postfix",
6537
6663
  latexTrigger: ["_"],
@@ -6614,6 +6740,29 @@ var Interval = (() => {
6614
6740
  return "";
6615
6741
  }
6616
6742
  },
6743
+ // Additional triggers for Range: `...`, `\ldots`, and `\dots` are
6744
+ // equivalent to `..` when used as infix operators (e.g. `[1...9]`).
6745
+ // No `name` field here — names must be unique per the dictionary rules;
6746
+ // the first Range entry owns the name. When there is no LHS the symbol
6747
+ // entries near the top of the file still fire (ContinuationPlaceholder).
6748
+ {
6749
+ latexTrigger: [".", ".", "."],
6750
+ kind: "infix",
6751
+ precedence: 800,
6752
+ parse: parseRange
6753
+ },
6754
+ {
6755
+ latexTrigger: ["\\ldots"],
6756
+ kind: "infix",
6757
+ precedence: 800,
6758
+ parse: parseRange
6759
+ },
6760
+ {
6761
+ latexTrigger: ["\\dots"],
6762
+ kind: "infix",
6763
+ precedence: 800,
6764
+ parse: parseRange
6765
+ },
6617
6766
  {
6618
6767
  latexTrigger: [";"],
6619
6768
  kind: "infix",
@@ -6798,13 +6947,24 @@ var Interval = (() => {
6798
6947
  const args = operands(expr);
6799
6948
  if (!args || args.length < 2) return "";
6800
6949
  const body = args[0];
6801
- const indexing = args[1];
6802
- if (operator(indexing) === "Element") {
6803
- const index = operand(indexing, 1);
6804
- const range = operand(indexing, 2);
6805
- if (operator(range) === "Range") {
6806
- const lo = operand(range, 1);
6807
- const hi = operand(range, 2);
6950
+ const elements = args.slice(1);
6951
+ const allElements = elements.every((e) => operator(e) === "Element");
6952
+ if (!allElements) {
6953
+ return joinLatex([
6954
+ "\\operatorname{Loop}(",
6955
+ serializer.serialize(body),
6956
+ ", ",
6957
+ serializer.serialize(elements[0]),
6958
+ ")"
6959
+ ]);
6960
+ }
6961
+ if (elements.length === 1) {
6962
+ const elem = elements[0];
6963
+ const index = operand(elem, 1);
6964
+ const coll = operand(elem, 2);
6965
+ if (operator(coll) === "Range") {
6966
+ const lo = operand(coll, 1);
6967
+ const hi = operand(coll, 2);
6808
6968
  return joinLatex([
6809
6969
  "\\text{for }",
6810
6970
  serializer.serialize(index),
@@ -6816,13 +6976,27 @@ var Interval = (() => {
6816
6976
  serializer.serialize(body)
6817
6977
  ]);
6818
6978
  }
6979
+ return joinLatex([
6980
+ serializer.serialize(body),
6981
+ " \\operatorname{for} ",
6982
+ serializer.serialize(index),
6983
+ " = ",
6984
+ serializer.serialize(coll)
6985
+ ]);
6819
6986
  }
6987
+ const bindings = elements.map((elem) => {
6988
+ const name = operand(elem, 1);
6989
+ const coll = operand(elem, 2);
6990
+ return joinLatex([
6991
+ serializer.serialize(name),
6992
+ " = ",
6993
+ serializer.serialize(coll)
6994
+ ]);
6995
+ }).join(", ");
6820
6996
  return joinLatex([
6821
- "\\operatorname{Loop}(",
6822
6997
  serializer.serialize(body),
6823
- ", ",
6824
- serializer.serialize(indexing),
6825
- ")"
6998
+ " \\operatorname{for} ",
6999
+ bindings
6826
7000
  ]);
6827
7001
  }
6828
7002
  },
@@ -6855,6 +7029,18 @@ var Interval = (() => {
6855
7029
  precedence: 245,
6856
7030
  parse: (parser, until) => parseForExpression(parser, until)
6857
7031
  },
7032
+ // \operatorname{for} as postfix infix (list comprehension):
7033
+ // `body \operatorname{for} x = L_1, y = L_2`
7034
+ // Precedence 19 — just below comma (20) so the body is allowed to use
7035
+ // any operator (including comma sequencing) up to the keyword, and the
7036
+ // bindings can be comma-separated below us.
7037
+ {
7038
+ symbolTrigger: "for",
7039
+ kind: "infix",
7040
+ associativity: "none",
7041
+ precedence: 19,
7042
+ parse: (parser, lhs, until) => parseForComprehension(parser, lhs, until)
7043
+ },
6858
7044
  // \operatorname{break}
6859
7045
  {
6860
7046
  symbolTrigger: "break",
@@ -7059,7 +7245,10 @@ var Interval = (() => {
7059
7245
  if (!sym || !parser.getSymbolType(sym).matches("function")) return null;
7060
7246
  parser.addBoundary([")"]);
7061
7247
  const expr = parser.parseExpression(until);
7062
- if (!parser.matchBoundary()) return null;
7248
+ if (!parser.matchBoundary()) {
7249
+ parser.removeBoundary();
7250
+ return null;
7251
+ }
7063
7252
  if (!parser.match("<}>")) return null;
7064
7253
  return ["Derivative", lhs, expr];
7065
7254
  }
@@ -7500,7 +7689,12 @@ var Interval = (() => {
7500
7689
  if (isEmptySequence(body)) return ["List"];
7501
7690
  const h = operator(body);
7502
7691
  if (h === "Range" || h === "Linspace") return body;
7503
- if (h === "Sequence") return ["List", ...operands(body)];
7692
+ if (h === "Sequence") {
7693
+ const elems = operands(body);
7694
+ const inferred = tryInferRangeFromElements(elems, parser);
7695
+ if (inferred) return inferred;
7696
+ return ["List", ...elems];
7697
+ }
7504
7698
  if (h === "Delimiter") {
7505
7699
  const delim = stringValue(operand(body, 2)) ?? "...";
7506
7700
  if (delim === ";" || delim === ".;.") {
@@ -7513,12 +7707,37 @@ var Interval = (() => {
7513
7707
  }
7514
7708
  if (delim === "," || delim === ".,.") {
7515
7709
  body = operand(body, 1);
7516
- if (operator(body) === "Sequence") return ["List", ...operands(body)];
7710
+ if (operator(body) === "Sequence") {
7711
+ const elems = operands(body);
7712
+ const inferred = tryInferRangeFromElements(elems, parser);
7713
+ if (inferred) return inferred;
7714
+ return ["List", ...elems];
7715
+ }
7517
7716
  return ["List", body ?? "Nothing"];
7518
7717
  }
7519
7718
  }
7520
7719
  return ["List", body];
7521
7720
  }
7721
+ function tryInferRangeFromElements(elems, parser) {
7722
+ if (elems.length < 4) return null;
7723
+ const penultimate = elems[elems.length - 2];
7724
+ if (symbol(penultimate) !== "ContinuationPlaceholder") return null;
7725
+ const samples = elems.slice(0, -2);
7726
+ const endExpr = elems[elems.length - 1];
7727
+ if (samples.length < 2) return null;
7728
+ const sampleNums = samples.map(machineValue);
7729
+ if (sampleNums.some((n) => n === null)) return null;
7730
+ const nums = sampleNums;
7731
+ const step = nums[nums.length - 1] - nums[nums.length - 2];
7732
+ const tol = parser.options.tolerance;
7733
+ if (Math.abs(step) < tol)
7734
+ return parser.error("degenerate-range-step", parser.index);
7735
+ for (let i = 1; i < nums.length; i++) {
7736
+ if (Math.abs(nums[i] - nums[i - 1] - step) > tol)
7737
+ return parser.error("inconsistent-range-samples", parser.index);
7738
+ }
7739
+ return ["Range", nums[0], endExpr, step];
7740
+ }
7522
7741
  function serializeList(serializer, expr) {
7523
7742
  if (nops(expr) > 1 && operands(expr).every((x) => {
7524
7743
  const op = operator(x);
@@ -7770,6 +7989,38 @@ var Interval = (() => {
7770
7989
  ["Element", index, ["Range", lower, upper]]
7771
7990
  ];
7772
7991
  }
7992
+ function parseForComprehension(parser, lhs, until) {
7993
+ const bindingTerminator = {
7994
+ minPrec: 21,
7995
+ // Above comma (20) and ; (19), so `x = L_1` is captured whole
7996
+ condition: (p) => {
7997
+ if (until?.condition?.(p)) return true;
7998
+ const saved = p.index;
7999
+ p.skipVisualSpace();
8000
+ const isComma = p.peek === ",";
8001
+ p.index = saved;
8002
+ if (isComma) return true;
8003
+ if (peekKeyword(p, "where")) return true;
8004
+ if (peekKeyword(p, "with")) return true;
8005
+ return false;
8006
+ }
8007
+ };
8008
+ const elements = [];
8009
+ do {
8010
+ parser.skipVisualSpace();
8011
+ const binding = parser.parseExpression(bindingTerminator);
8012
+ if (binding === null) break;
8013
+ const op = operator(binding);
8014
+ if (op !== "Equal" && op !== "Assign") return null;
8015
+ const name = operand(binding, 1);
8016
+ const list = operand(binding, 2);
8017
+ if (!name || !list) return null;
8018
+ elements.push(["Element", name, list]);
8019
+ parser.skipVisualSpace();
8020
+ } while (parser.match(","));
8021
+ if (elements.length === 0) return null;
8022
+ return ["Loop", lhs, ...elements];
8023
+ }
7773
8024
  function parseWhereExpression(parser, lhs, until) {
7774
8025
  const bindingTerminator = {
7775
8026
  minPrec: 21,
@@ -7792,6 +8043,25 @@ var Interval = (() => {
7792
8043
  parser.skipVisualSpace();
7793
8044
  } while (parser.match(","));
7794
8045
  if (bindings.length === 0) return null;
8046
+ const forStart = parser.index;
8047
+ if (matchKeyword(parser, "for")) {
8048
+ const loop = parseForComprehension(parser, lhs, until);
8049
+ if (loop) {
8050
+ const block2 = [];
8051
+ for (const b of bindings) {
8052
+ const normalized = normalizeLocalAssign(b);
8053
+ if (operator(normalized) === "Assign") {
8054
+ block2.push(["Declare", operand(normalized, 1)]);
8055
+ block2.push(normalized);
8056
+ } else {
8057
+ block2.push(normalized);
8058
+ }
8059
+ }
8060
+ block2.push(loop);
8061
+ return ["Block", ...block2];
8062
+ }
8063
+ parser.index = forStart;
8064
+ }
7795
8065
  const block = [];
7796
8066
  for (const b of bindings) {
7797
8067
  const normalized = normalizeLocalAssign(b);
@@ -8005,6 +8275,17 @@ var Interval = (() => {
8005
8275
  const upperExpr = openRight ? ["Open", upper] : upper;
8006
8276
  return ["Interval", lowerExpr, upperExpr];
8007
8277
  }
8278
+ var COMPARISON_HEADS = /* @__PURE__ */ new Set([
8279
+ "Less",
8280
+ "LessEqual",
8281
+ "Greater",
8282
+ "GreaterEqual",
8283
+ "Equal",
8284
+ "NotEqual",
8285
+ "And",
8286
+ "Or",
8287
+ "Not"
8288
+ ]);
8008
8289
  var DEFINITIONS_SETS = [
8009
8290
  //
8010
8291
  // Constants
@@ -8263,18 +8544,58 @@ var Interval = (() => {
8263
8544
  closeTrigger: "}",
8264
8545
  parse: (_parser, body) => {
8265
8546
  if (isEmptySequence(body)) return "EmptySet";
8547
+ if (operator(body) == "Delimiter" && stringValue(operand(body, 2)) === ",") {
8548
+ body = operand(body, 1);
8549
+ }
8266
8550
  const h = operator(body);
8267
- if (h === "Divides" || h === "Colon") {
8551
+ if (h === "Divides") {
8268
8552
  const expr = operand(body, 1);
8269
8553
  const condition = operand(body, 2);
8270
8554
  if (expr !== null && condition !== null)
8271
8555
  return ["Set", expr, ["Condition", condition]];
8272
8556
  }
8273
- if (operator(body) == "Delimiter" && stringValue(operand(body, 2)) === ",") {
8274
- body = operand(body, 1);
8557
+ if (h === "Colon") {
8558
+ const lhs = operand(body, 1);
8559
+ const rhs = operand(body, 2);
8560
+ if (lhs !== null && rhs !== null) {
8561
+ const lhsOp = operator(lhs);
8562
+ if (lhsOp !== null && COMPARISON_HEADS.has(lhsOp)) {
8563
+ return ["Which", lhs, rhs];
8564
+ }
8565
+ return ["Set", lhs, ["Condition", rhs]];
8566
+ }
8567
+ }
8568
+ if (h === "Sequence") {
8569
+ const elements = operands(body);
8570
+ const colonElements = elements.filter((el) => operator(el) === "Colon");
8571
+ const allPiecewise = colonElements.length > 0 && colonElements.every((el) => {
8572
+ const lhs = operand(el, 1);
8573
+ const lhsOp = lhs !== null ? operator(lhs) : null;
8574
+ return lhsOp !== null && COMPARISON_HEADS.has(lhsOp);
8575
+ });
8576
+ if (allPiecewise) {
8577
+ const whichOps = [];
8578
+ for (let i = 0; i < elements.length; i++) {
8579
+ const el = elements[i];
8580
+ if (operator(el) === "Colon") {
8581
+ const cond = operand(el, 1);
8582
+ const val = operand(el, 2);
8583
+ if (cond === null || val === null) {
8584
+ return ["Set", ...elements];
8585
+ }
8586
+ whichOps.push(cond, val);
8587
+ } else {
8588
+ if (i !== elements.length - 1) {
8589
+ return ["Set", ...elements];
8590
+ }
8591
+ whichOps.push("True", el);
8592
+ }
8593
+ }
8594
+ return ["Which", ...whichOps];
8595
+ }
8596
+ return ["Set", ...elements];
8275
8597
  }
8276
- if (operator(body) !== "Sequence") return ["Set", body];
8277
- return ["Set", ...operands(body)];
8598
+ return ["Set", body];
8278
8599
  },
8279
8600
  serialize: (serializer, expr) => {
8280
8601
  if (nops(expr) === 2 && operator(operand(expr, 2)) === "Condition") {
@@ -10248,7 +10569,8 @@ var Interval = (() => {
10248
10569
  minPrec: MULTIPLICATION_PRECEDENCE,
10249
10570
  condition: (parser2) => trigCommands[parser2.peek] || (until?.condition?.(parser2) ?? false)
10250
10571
  });
10251
- const appliedFn = args === null ? fn : typeof fn === "string" ? [fn, ...args] : ["Apply", fn, ...args];
10572
+ const head = fn === "Arctan" && args?.length === 2 ? "Arctan2" : fn;
10573
+ const appliedFn = args === null ? fn : typeof head === "string" ? [head, ...args] : ["Apply", head, ...args];
10252
10574
  return sup === null ? appliedFn : ["Power", appliedFn, sup];
10253
10575
  };
10254
10576
  }
@@ -12371,10 +12693,17 @@ var Interval = (() => {
12371
12693
  // The capitalized library entries already exist; these are pure parse
12372
12694
  // aliases so the lowercase names don't land in `unsupported-operator`.
12373
12695
  // ---------------------------------------------------------------------------
12696
+ { latexTrigger: "\\operatorname{count}", parse: "Length" },
12374
12697
  { latexTrigger: "\\operatorname{random}", parse: "Random" },
12375
12698
  { latexTrigger: "\\operatorname{shuffle}", parse: "Shuffle" },
12376
12699
  { latexTrigger: "\\operatorname{repeat}", parse: "Repeat" },
12377
12700
  { latexTrigger: "\\operatorname{join}", parse: "Join" },
12701
+ { latexTrigger: "\\operatorname{range}", parse: "Range" },
12702
+ // Note: `\operatorname{with}` (Desmos's local-binding clause) is intentionally
12703
+ // NOT registered here. Use the math-notation equivalent `\operatorname{where}`
12704
+ // (with `\coloneq` for bindings), or register `with` as a custom dictionary
12705
+ // entry at the integration layer — see the "Desmos-Specific Syntax — Prefer
12706
+ // Custom LaTeX Dictionary" section in COMPUTE_ENGINE.md for a worked example.
12378
12707
  // ---------------------------------------------------------------------------
12379
12708
  // Geometric primitive heads. Registered as known typed heads so consumers
12380
12709
  // can branch on the operator name; CE itself doesn't render them. The
@@ -13653,7 +13982,7 @@ var Interval = (() => {
13653
13982
  };
13654
13983
 
13655
13984
  // src/interval.ts
13656
- var version = "0.56.0";
13985
+ var version = "0.58.0";
13657
13986
  return __toCommonJS(interval_exports);
13658
13987
  })();
13659
13988
  /*! Bundled license information: