@cortex-js/compute-engine 0.16.0 → 0.18.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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/compute-engine.esm.js +4235 -3949
  3. package/dist/compute-engine.js +4235 -3949
  4. package/dist/compute-engine.min.esm.js +50 -27363
  5. package/dist/compute-engine.min.js +22 -27346
  6. package/dist/math-json.esm.js +2 -2
  7. package/dist/math-json.js +2 -2
  8. package/dist/math-json.min.esm.js +2 -2
  9. package/dist/math-json.min.js +2 -281
  10. package/dist/types/common/ansi-codes.d.ts +1 -1
  11. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  12. package/dist/types/common/signals.d.ts +1 -1
  13. package/dist/types/common/utils.d.ts +1 -1
  14. package/dist/types/compute-engine/assume.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +7 -8
  16. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +7 -7
  18. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +13 -25
  19. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -2
  20. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +6 -6
  21. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +4 -3
  22. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
  23. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +3 -3
  25. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +11 -11
  26. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +2 -2
  29. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/validate.d.ts +32 -12
  31. package/dist/types/compute-engine/compile.d.ts +22 -2
  32. package/dist/types/compute-engine/compute-engine.d.ts +28 -38
  33. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  34. package/dist/types/compute-engine/domain-utils.d.ts +4 -6
  35. package/dist/types/compute-engine/function-utils.d.ts +41 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  52. package/dist/types/compute-engine/latex-syntax/public.d.ts +36 -23
  53. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  57. package/dist/types/compute-engine/library/arithmetic-add.d.ts +2 -2
  58. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  59. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
  60. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  61. package/dist/types/compute-engine/library/arithmetic.d.ts +2 -2
  62. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  63. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  64. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  65. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  66. package/dist/types/compute-engine/library/core.d.ts +1 -1
  67. package/dist/types/compute-engine/library/domains.d.ts +3 -2
  68. package/dist/types/compute-engine/library/library.d.ts +4 -2
  69. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  70. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  71. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  72. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  73. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  74. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  75. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  76. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  77. package/dist/types/compute-engine/library/utils.d.ts +1 -3
  78. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  79. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  80. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  81. package/dist/types/compute-engine/numerics/numeric.d.ts +10 -2
  82. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  83. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  84. package/dist/types/compute-engine/numerics/richardson.d.ts +80 -0
  85. package/dist/types/compute-engine/public.d.ts +91 -113
  86. package/dist/types/compute-engine/rules.d.ts +1 -1
  87. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  88. package/dist/types/compute-engine/solve.d.ts +1 -1
  89. package/dist/types/compute-engine/symbolic/derivative.d.ts +16 -2
  90. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  91. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -2
  92. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  93. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  94. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  95. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  96. package/dist/types/compute-engine/symbolic/utils.d.ts +5 -3
  97. package/dist/types/compute-engine.d.ts +2 -2
  98. package/dist/types/math-json/math-json-format.d.ts +4 -3
  99. package/dist/types/math-json/utils.d.ts +1 -1
  100. package/dist/types/math-json.d.ts +2 -2
  101. package/package.json +9 -1
@@ -1,4 +1,4 @@
1
- /** CortexJS Compute Engine 0.16.0 */
1
+ /** CortexJS Compute Engine 0.18.0 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  function isSymbolObject(expr) {
@@ -239,7 +239,7 @@ function mapArgs(expr, fn) {
239
239
  }
240
240
 
241
241
  // src/math-json.ts
242
- var version = "0.16.0";
242
+ var version = "0.18.0";
243
243
  export {
244
244
  applyRecursively,
245
245
  dictionary as getDictionary,
package/dist/math-json.js CHANGED
@@ -1,4 +1,4 @@
1
- /** CortexJS MathJSON 0.16.0 */
1
+ /** CortexJS MathJSON 0.18.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.MathJson = {}));})(this, (function (exports) { 'use strict';
3
3
  var MathJson = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -277,7 +277,7 @@ var MathJson = (() => {
277
277
  }
278
278
 
279
279
  // src/math-json.ts
280
- var version = "0.16.0";
280
+ var version = "0.18.0";
281
281
  return __toCommonJS(math_json_exports);
282
282
  })();
283
283
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /** CortexJS Compute Engine 0.16.0 */
1
+ /** CortexJS Compute Engine 0.18.0 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  function isSymbolObject(expr) {
@@ -239,7 +239,7 @@ function mapArgs(expr, fn) {
239
239
  }
240
240
 
241
241
  // src/math-json.ts
242
- var version = "0.16.0";
242
+ var version = "0.18.0";
243
243
  export {
244
244
  applyRecursively,
245
245
  dictionary as getDictionary,
@@ -1,283 +1,4 @@
1
- /** CortexJS MathJSON 0.16.0 */
1
+ /** CortexJS MathJSON 0.18.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.MathJson = {}));})(this, (function (exports) { 'use strict';
3
- var MathJson = (() => {
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/math-json.ts
23
- var math_json_exports = {};
24
- __export(math_json_exports, {
25
- applyRecursively: () => applyRecursively,
26
- getDictionary: () => dictionary,
27
- getStringValue: () => stringValue,
28
- head: () => head,
29
- headName: () => headName,
30
- isDictionaryObject: () => isDictionaryObject,
31
- isFunctionObject: () => isFunctionObject,
32
- isStringObject: () => isStringObject,
33
- isSymbolObject: () => isSymbolObject,
34
- mapArgs: () => mapArgs,
35
- nops: () => nops,
36
- op: () => op,
37
- symbol: () => symbol,
38
- version: () => version
39
- });
40
-
41
- // src/math-json/utils.ts
42
- function isSymbolObject(expr) {
43
- return expr !== null && typeof expr === "object" && "sym" in expr;
44
- }
45
- function isStringObject(expr) {
46
- return expr !== null && typeof expr === "object" && "str" in expr;
47
- }
48
- function isFunctionObject(expr) {
49
- return expr !== null && typeof expr === "object" && "fn" in expr;
50
- }
51
- function isDictionaryObject(expr) {
52
- return expr !== null && typeof expr === "object" && "dict" in expr;
53
- }
54
- var recommendedScriptsRegex;
55
- function isRecommendedScripts(text) {
56
- if (!recommendedScriptsRegex) {
57
- const recommendedScripts = [
58
- "Zyyy",
59
- "Zinh",
60
- "Arab",
61
- "Armn",
62
- "Beng",
63
- "Bopo",
64
- "Cyrl",
65
- "Deva",
66
- "Ethi",
67
- "Geor",
68
- "Grek",
69
- "Gujr",
70
- "Guru",
71
- "Hang",
72
- "Hani",
73
- "Hebr",
74
- "Hira",
75
- "Kana",
76
- "Knda",
77
- "Khmr",
78
- "Laoo",
79
- "Latn",
80
- "Mlym",
81
- "Mymr",
82
- "Orya",
83
- "Sinh",
84
- "Taml",
85
- "Telu",
86
- "Thaa",
87
- "Thai",
88
- "Tibt"
89
- ];
90
- const regexPattern = `^[${recommendedScripts.map((x) => `\\p{Script=${x}}`).join("")}]*$`;
91
- recommendedScriptsRegex = new RegExp(regexPattern, "u");
92
- }
93
- return recommendedScriptsRegex.test(text);
94
- }
95
- function isValidIdentifier(s) {
96
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))
97
- return true;
98
- if (ONLY_EMOJIS.test(s))
99
- return true;
100
- if (!isRecommendedScripts(s))
101
- return false;
102
- return /^[\p{XIDS}_]\p{XIDC}*$/u.test(s);
103
- }
104
- var VS16 = "\\u{FE0F}";
105
- var KEYCAP = "\\u{20E3}";
106
- var ZWJ = "\\u{200D}";
107
- var FLAG_SEQUENCE = "\\p{RI}\\p{RI}";
108
- var TAG_MOD = `(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})`;
109
- var EMOJI_MOD = `(?:\\p{EMod}|${VS16}${KEYCAP}?|${TAG_MOD})`;
110
- var EMOJI_NOT_IDENTIFIER = `(?:(?=\\P{XIDC})\\p{Emoji})`;
111
- var ZWJ_ELEMENT = `(?:${EMOJI_NOT_IDENTIFIER}${EMOJI_MOD}*|\\p{Emoji}${EMOJI_MOD}+|${FLAG_SEQUENCE})`;
112
- var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ}${ZWJ_ELEMENT})*`;
113
- var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
114
- var ONLY_EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
115
- function validateIdentifier(s) {
116
- if (typeof s !== "string")
117
- return "not-a-string";
118
- if (s === "")
119
- return "empty-string";
120
- if (s.normalize() !== s)
121
- return "expected-nfc";
122
- if (/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(s))
123
- return "unexpected-bidi-marker";
124
- if (ONLY_EMOJIS.test(s))
125
- return "valid";
126
- if (/\p{XIDC}/u.test(s) && SOME_EMOJI.test(s))
127
- return "unexpected-mixed-emoji";
128
- if (!isRecommendedScripts(s))
129
- return "unexpected-script";
130
- if (!isValidIdentifier(s)) {
131
- if (!isValidIdentifier(s[0]))
132
- return "invalid-first-char";
133
- return "invalid-char";
134
- }
135
- return "valid";
136
- }
137
- function stringValue(expr) {
138
- if (expr === null || expr === void 0)
139
- return null;
140
- if (typeof expr === "object" && "str" in expr)
141
- return expr.str;
142
- if (typeof expr !== "string")
143
- return null;
144
- if (expr.length < 2)
145
- return null;
146
- if (expr[0] !== "'" || expr[expr.length - 1] !== "'")
147
- return null;
148
- return expr.substring(1, expr.length - 1);
149
- }
150
- function head(expr) {
151
- if (expr === null || expr === void 0)
152
- return null;
153
- if (Array.isArray(expr)) {
154
- if (typeof expr[0] === "string" && !isValidIdentifier(expr[0])) {
155
- console.error(
156
- `Invalid identifier "${expr[0]}": ${validateIdentifier(expr[0])}`
157
- );
158
- return null;
159
- }
160
- return expr[0];
161
- }
162
- if (isFunctionObject(expr))
163
- return expr.fn[0];
164
- return null;
165
- }
166
- function headName(expr) {
167
- const h = head(expr);
168
- return typeof h === "string" ? h : "";
169
- }
170
- function ops(expr) {
171
- if (expr === null || expr === void 0)
172
- return null;
173
- if (Array.isArray(expr))
174
- return expr.slice(1);
175
- if (isFunctionObject(expr))
176
- return expr.fn.slice(1);
177
- return null;
178
- }
179
- function op(expr, n) {
180
- if (expr === null || expr === void 0)
181
- return null;
182
- if (Array.isArray(expr))
183
- return expr[n] ?? null;
184
- if (isFunctionObject(expr))
185
- return expr.fn[n] ?? null;
186
- return null;
187
- }
188
- function op1(expr) {
189
- return op(expr, 1);
190
- }
191
- function op2(expr) {
192
- return op(expr, 2);
193
- }
194
- function nops(expr) {
195
- if (expr === null || expr === void 0)
196
- return 0;
197
- if (Array.isArray(expr))
198
- return Math.max(0, expr.length - 1);
199
- if (isFunctionObject(expr))
200
- return Math.max(0, expr.fn.length - 1);
201
- return 0;
202
- }
203
- function symbol(expr) {
204
- if (expr === null || expr === void 0)
205
- return null;
206
- if (typeof expr === "string") {
207
- if (/^[+\-\.0-9]/.test(expr))
208
- return null;
209
- if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
210
- return null;
211
- }
212
- const s = isSymbolObject(expr) ? expr.sym : expr;
213
- if (typeof s !== "string")
214
- return null;
215
- return s;
216
- }
217
- function keyValuePair(expr) {
218
- const h = head(expr);
219
- if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
220
- const key = stringValue(op1(expr));
221
- if (!key)
222
- return null;
223
- return [key, op2(expr) ?? "Nothing"];
224
- }
225
- return null;
226
- }
227
- function dictionary(expr) {
228
- if (expr === null)
229
- return null;
230
- if (typeof expr === "object" && "dict" in expr)
231
- return expr.dict;
232
- const kv = keyValuePair(expr);
233
- if (kv)
234
- return { [kv[0]]: kv[1] };
235
- const h = head(expr);
236
- if (h === "Dictionary") {
237
- const result = {};
238
- for (let i = 1; i < nops(expr); i++) {
239
- const kv2 = keyValuePair(op(expr, i));
240
- if (kv2)
241
- result[kv2[0]] = kv2[1];
242
- }
243
- return result;
244
- }
245
- return null;
246
- }
247
- function applyRecursively(expr, fn) {
248
- const h = head(expr);
249
- if (h !== null) {
250
- return [fn(h), ...(ops(expr) ?? []).map(fn)];
251
- }
252
- const dict = dictionary(expr);
253
- if (dict !== null) {
254
- const keys = Object.keys(dict);
255
- const result = {};
256
- for (const key of keys)
257
- result[key] = fn(dict[key]);
258
- return { dict: result };
259
- }
260
- return fn(expr);
261
- }
262
- function mapArgs(expr, fn) {
263
- let args = null;
264
- if (Array.isArray(expr))
265
- args = expr;
266
- if (isFunctionObject(expr))
267
- args = expr.fn;
268
- if (args === null)
269
- return [];
270
- let i = 1;
271
- const result = [];
272
- while (i < args.length) {
273
- result.push(fn(args[i]));
274
- i += 1;
275
- }
276
- return result;
277
- }
278
-
279
- // src/math-json.ts
280
- var version = "0.16.0";
281
- return __toCommonJS(math_json_exports);
282
- })();
3
+ var MathJson=(()=>{var f=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var D=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},R=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of k(t))!v.call(n,r)&&r!==e&&f(n,r,{get:()=>t[r],enumerable:!(i=J(t,r))||i.enumerable});return n};var _=n=>R(f({},"__esModule",{value:!0}),n);var z={};D(z,{applyRecursively:()=>T,getDictionary:()=>y,getStringValue:()=>m,head:()=>o,headName:()=>I,isDictionaryObject:()=>M,isFunctionObject:()=>u,isStringObject:()=>S,isSymbolObject:()=>d,mapArgs:()=>$,nops:()=>E,op:()=>s,symbol:()=>A,version:()=>X});function d(n){return n!==null&&typeof n=="object"&&"sym"in n}function S(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function M(n){return n!==null&&typeof n=="object"&&"dict"in n}var c;function N(n){if(!c){let e=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;c=new RegExp(e,"u")}return c.test(n)}function a(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||O.test(n)?!0:N(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var F="\\u{FE0F}",L="\\u{20E3}",w="\\u{200D}",V="\\p{RI}\\p{RI}",P="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",b=`(?:\\p{EMod}|${F}${L}?|${P})`,q="(?:(?=\\P{XIDC})\\p{Emoji})",h=`(?:${q}${b}*|\\p{Emoji}${b}+|${V})`,j=`(?:${h})(${w}${h})*`,C=new RegExp(`(?:${j})+`,"u"),O=new RegExp(`^(?:${j})+$`,"u");function G(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":O.test(n)?"valid":/\p{XIDC}/u.test(n)&&C.test(n)?"unexpected-mixed-emoji":N(n)?a(n)?"valid":a(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}function m(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n[0]!=="'"||n[n.length-1]!=="'"?null:n.substring(1,n.length-1)}function o(n){return n==null?null:Array.isArray(n)?typeof n[0]=="string"&&!a(n[0])?(console.error(`Invalid identifier "${n[0]}": ${G(n[0])}`),null):n[0]:u(n)?n.fn[0]:null}function I(n){let t=o(n);return typeof t=="string"?t:""}function K(n){return n==null?null:Array.isArray(n)?n.slice(1):u(n)?n.fn.slice(1):null}function s(n,t){return n==null?null:Array.isArray(n)?n[t]??null:u(n)?n.fn[t]??null:null}function Z(n){return s(n,1)}function H(n){return s(n,2)}function E(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function A(n){if(n==null||typeof n=="string"&&(/^[+\-\.0-9]/.test(n)||n.length>=2&&n[0]==="'"&&n[n.length-1]==="'"))return null;let t=d(n)?n.sym:n;return typeof t!="string"?null:t}function p(n){let t=o(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let e=m(Z(n));return e?[e,H(n)??"Nothing"]:null}return null}function y(n){if(n===null)return null;if(typeof n=="object"&&"dict"in n)return n.dict;let t=p(n);if(t)return{[t[0]]:t[1]};if(o(n)==="Dictionary"){let i={};for(let r=1;r<E(n);r++){let l=p(s(n,r));l&&(i[l[0]]=l[1])}return i}return null}function T(n,t){let e=o(n);if(e!==null)return[t(e),...(K(n)??[]).map(t)];let i=y(n);if(i!==null){let r=Object.keys(i),l={};for(let g of r)l[g]=t(i[g]);return{dict:l}}return t(n)}function $(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let i=1,r=[];for(;i<e.length;)r.push(t(e[i])),i+=1;return r}var X="0.18.0";return _(z);})();
283
4
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  export declare const BLACK = "\u001B[30;1m${s}";
3
3
  export declare const GREY = "\u001B[30;1m${s}";
4
4
  export declare const GREEN = "\u001B[32;1m";
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  export type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
3
3
  export type SignalMessage = SignalCode | [SignalCode, ...any[]];
4
4
  export type SignalOrigin = {
@@ -1 +1 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,7 +1,7 @@
1
- /* 0.16.0 */
2
- import { Complex } from 'complex.js';
1
+ /* 0.18.0 */
2
+ import type { Decimal } from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SemiBoxedExpression, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution } from '../public';
4
+ import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution } from '../public';
5
5
  /**
6
6
  * _BoxedExpression
7
7
  */
@@ -56,7 +56,6 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
56
56
  /** For a symbol, true if the symbol is a constant (unchangeable value) */
57
57
  get isConstant(): boolean;
58
58
  get canonical(): BoxedExpression;
59
- apply(_fn: (x: BoxedExpression) => SemiBoxedExpression, _head?: string): BoxedExpression;
60
59
  subs(_sub: Substitution, options?: {
61
60
  canonical: boolean;
62
61
  }): BoxedExpression;
@@ -93,15 +92,15 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
93
92
  get symbolDefinition(): BoxedSymbolDefinition | undefined;
94
93
  get functionDefinition(): BoxedFunctionDefinition | undefined;
95
94
  infer(_domain: BoxedDomain): boolean;
96
- bind(_scope: RuntimeScope | null): void;
97
- unbind(): void;
95
+ bind(): void;
96
+ reset(): void;
98
97
  get keys(): IterableIterator<string> | null;
99
98
  get keysCount(): number;
100
99
  getKey(_key: string): BoxedExpression | undefined;
101
100
  hasKey(_key: string): boolean;
102
101
  get value(): BoxedExpression | undefined;
103
102
  set value(_value: BoxedExpression | number | undefined);
104
- get domain(): BoxedDomain;
103
+ get domain(): BoxedDomain | undefined;
105
104
  set domain(_domain: BoxedDomain);
106
105
  get isNumber(): boolean | undefined;
107
106
  get isInteger(): boolean | undefined;
@@ -113,7 +112,7 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
113
112
  get isImaginary(): boolean | undefined;
114
113
  get isExtendedComplex(): boolean | undefined;
115
114
  simplify(_options?: SimplifyOptions): BoxedExpression;
116
- evaluate(options?: EvaluateOptions): BoxedExpression;
115
+ evaluate(_options?: EvaluateOptions): BoxedExpression;
117
116
  N(_options?: NOptions): BoxedExpression;
118
117
  compile(to?: string, options?: {
119
118
  optimize: ('simplify' | 'evaluate')[];
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, Rational } from '../public';
4
4
  import { MathJsonNumber } from '../../math-json/math-json-format';
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution } from '../public';
3
3
  import { _BoxedExpression } from './abstract-boxed-expression';
4
4
  /**
@@ -9,11 +9,12 @@ export declare class BoxedDictionary extends _BoxedExpression {
9
9
  private _isCanonical;
10
10
  constructor(ce: IComputeEngine, dict: {
11
11
  [key: string]: SemiBoxedExpression;
12
- }, options?: {
12
+ } | Map<string, BoxedExpression>, options?: {
13
13
  canonical?: boolean;
14
14
  metadata?: Metadata;
15
15
  });
16
- unbind(): undefined;
16
+ bind(): void;
17
+ reset(): undefined;
17
18
  get hash(): number;
18
19
  get complexity(): number;
19
20
  get head(): 'Dictionary';
@@ -30,13 +31,12 @@ export declare class BoxedDictionary extends _BoxedExpression {
30
31
  match(rhs: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
31
32
  /** Mathematical equality */
32
33
  isEqual(rhs: BoxedExpression): boolean;
33
- apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
34
- evaluate(options?: EvaluateOptions): BoxedExpression;
34
+ evaluate(_options?: EvaluateOptions): BoxedExpression;
35
35
  get isCanonical(): boolean;
36
36
  set isCanonical(val: boolean);
37
37
  get canonical(): BoxedExpression;
38
- simplify(options?: SimplifyOptions): BoxedExpression;
39
- N(options?: NOptions): BoxedExpression;
38
+ simplify(_options?: SimplifyOptions): BoxedExpression;
39
+ N(_options?: NOptions): BoxedExpression;
40
40
  replace(rules: BoxedRuleSet, options?: ReplaceOptions): null | BoxedExpression;
41
41
  subs(sub: Substitution, options?: {
42
42
  canonical: boolean;
@@ -1,51 +1,39 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  import { BoxedDomain, BoxedExpression, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
3
3
  import { _BoxedExpression } from './abstract-boxed-expression';
4
4
  /**
5
- * A `_BoxedDomain` is a wrapper around a boxed, canonical, domain expression.
5
+ * A `_BoxedDomain` is a wrapper around a boxed, canonical, domain
6
+ * expression.
6
7
  *
7
- * If could also be an error, in which case, `isValid` is `false`.
8
+ * It could be an invalid domain, in which case `isValid` is `false`.
8
9
  *
9
10
  */
10
11
  export declare class _BoxedDomain extends _BoxedExpression implements BoxedDomain {
11
- /** The value of a boxed domain is either a string if a domain literal, or a
12
- * domain constructor function.
13
- * Since the domains are alway canonicalized when boxed, their value can
14
- * be represented by a simple array, without the need for extra boxing.
15
- */
16
- _value: DomainLiteral | DomainExpression<BoxedExpression>;
17
12
  private _hash;
13
+ readonly base: DomainLiteral;
14
+ readonly ctor: DomainConstructor | null;
15
+ readonly params: BoxedDomain[];
16
+ readonly optParams: BoxedDomain[];
17
+ readonly restParam: BoxedDomain | null;
18
+ readonly result: BoxedDomain | null;
18
19
  constructor(ce: IComputeEngine, dom: DomainExpression, metadata?: Metadata);
19
- get isCanonical(): boolean;
20
20
  /** Boxed domains are always canonical. */
21
+ get isCanonical(): boolean;
21
22
  get canonical(): _BoxedDomain;
22
23
  get isValid(): boolean;
23
24
  get json(): Expression;
24
- get literal(): string | null;
25
- get ctor(): DomainConstructor | null;
26
- get domainArgs(): (string | BoxedExpression | DomainExpression<BoxedExpression>)[] | null;
27
- get codomain(): BoxedDomain | null;
28
25
  get hash(): number;
26
+ isCompatible(dom: BoxedDomain | DomainLiteral, compatibility?: DomainCompatibility): boolean;
29
27
  isEqual(rhs: BoxedExpression): boolean;
30
28
  isSame(rhs: BoxedExpression): boolean;
31
- is(rhs: any): boolean;
32
- isCompatible(dom: BoxedDomain | DomainLiteral, compatibility?: DomainCompatibility): boolean;
33
29
  match(rhs: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
34
30
  get head(): string;
35
31
  get domain(): BoxedDomain;
36
- get isNothing(): boolean;
37
32
  get isFunction(): boolean;
38
33
  get isNumeric(): boolean;
39
- get isRelationalOperator(): boolean;
40
34
  }
41
- /**
42
- * Note that `boxDomain()` should only be called from `ComputeEngine`.
43
- * This gives a chance for `ComputeEngine` to substitute cached objects.
44
- */
45
- export declare function boxDomain(ce: IComputeEngine, dom: BoxedExpression | DomainExpression, metadata?: Metadata): BoxedDomain;
46
35
  /** Validate that `expr` is a Domain */
47
36
  export declare function isDomain(expr: Expression | BoxedExpression | BoxedDomain | DomainExpression): expr is BoxedDomain | DomainExpression;
48
- export declare function isValidDomain(expr: any): expr is BoxedDomain | DomainExpression;
49
37
  /** Return the ancestor domain that is shared by both `a` and `b` */
50
- export declare function widen(a: BoxedDomain | undefined | null, b: BoxedDomain | undefined | null): BoxedDomain;
38
+ export declare function widen(a: BoxedDomain | undefined | null, b: BoxedDomain | undefined | null): BoxedDomain | undefined;
51
39
  export declare function narrow(a: BoxedDomain | undefined, b: BoxedDomain | undefined): BoxedDomain;
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition {
3
3
  engine: IComputeEngine;
4
4
  scope: RuntimeScope;
@@ -14,7 +14,7 @@ export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition
14
14
  inert: boolean;
15
15
  numeric: boolean;
16
16
  complexity: number;
17
- hold: 'none' | 'all' | 'first' | 'rest' | 'last' | 'most';
17
+ hold: Hold;
18
18
  dynamic: boolean;
19
19
  signature: BoxedFunctionSignature;
20
20
  iterator?: (expr: BoxedExpression, start?: number, count?: number) => Iterator<BoxedExpression>;
@@ -1,6 +1,6 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
- import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions, BoxedBaseDefinition } from '../public';
3
+ import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions, BoxedBaseDefinition, Hold } from '../public';
4
4
  /**
5
5
  * BoxedFunction
6
6
  */
@@ -20,6 +20,8 @@ export declare class BoxedFunction extends _BoxedExpression {
20
20
  canonical?: boolean;
21
21
  });
22
22
  get hash(): number;
23
+ bind(): void;
24
+ reset(): void;
23
25
  get isCanonical(): boolean;
24
26
  set isCanonical(val: boolean);
25
27
  get isPure(): boolean;
@@ -46,8 +48,6 @@ export declare class BoxedFunction extends _BoxedExpression {
46
48
  get complexity(): number | undefined;
47
49
  get baseDefinition(): BoxedBaseDefinition | undefined;
48
50
  get functionDefinition(): BoxedFunctionDefinition | undefined;
49
- bind(_scope?: RuntimeScope | null): void;
50
- unbind(): void;
51
51
  get value(): BoxedExpression | undefined;
52
52
  /** `isEqual` is mathematical equality */
53
53
  isEqual(rhs: BoxedExpression): boolean;
@@ -72,7 +72,7 @@ export declare class BoxedFunction extends _BoxedExpression {
72
72
  get isComplex(): boolean | undefined;
73
73
  get isImaginary(): boolean | undefined;
74
74
  get sgn(): -1 | 0 | 1 | undefined | null;
75
- get domain(): BoxedDomain;
75
+ get domain(): BoxedDomain | undefined;
76
76
  simplify(options?: SimplifyOptions): BoxedExpression;
77
77
  evaluate(options?: EvaluateOptions): BoxedExpression;
78
78
  N(options?: NOptions): BoxedExpression;
@@ -92,4 +92,4 @@ export declare function makeCanonicalFunction(ce: IComputeEngine, head: string |
92
92
  *
93
93
  * If `f` returns `null`, the element is not added to the result
94
94
  */
95
- export declare function holdMap(xs: BoxedExpression[], skip: 'all' | 'none' | 'first' | 'rest' | 'last' | 'most', associativeHead: string, f: (x: BoxedExpression) => BoxedExpression | null): BoxedExpression[];
95
+ export declare function holdMap(xs: BoxedExpression[], skip: Hold, associativeHead: string, f: (x: BoxedExpression) => BoxedExpression | null): BoxedExpression[];
@@ -1,7 +1,7 @@
1
- /* 0.16.0 */
2
- import { Complex } from 'complex.js';
1
+ /* 0.18.0 */
2
+ import { Decimal } from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution } from '../public';
4
+ import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution, EvaluateOptions } from '../public';
5
5
  import { _BoxedExpression } from './abstract-boxed-expression';
6
6
  /**
7
7
  * BoxedNumber
@@ -81,5 +81,6 @@ export declare class BoxedNumber extends _BoxedExpression {
81
81
  get isExtendedComplex(): boolean | undefined;
82
82
  get canonical(): BoxedExpression;
83
83
  simplify(_options?: SimplifyOptions): BoxedExpression;
84
+ evaluate(options?: EvaluateOptions): BoxedExpression;
84
85
  N(_options?: NOptions): BoxedExpression;
85
86
  }
@@ -1,11 +1,11 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  import { _BoxedExpression } from './abstract-boxed-expression';
3
3
  import { BoxedExpression, BoxedSubstitution, BoxedDomain, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOptions, SemiBoxedExpression, Substitution } from '../public';
4
4
  export declare class BoxedPattern extends _BoxedExpression implements Pattern {
5
5
  _pattern: BoxedExpression;
6
6
  constructor(ce: IComputeEngine, pattern: LatexString | SemiBoxedExpression, metadata?: Metadata);
7
7
  get hash(): number;
8
- unbind(): void;
8
+ reset(): void;
9
9
  get json(): Expression;
10
10
  get head(): string | BoxedExpression;
11
11
  get domain(): BoxedDomain;
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  import { _BoxedExpression } from './abstract-boxed-expression';
3
3
  import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution } from '../public';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.16.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * ## THEORY OF OPERATIONS
4
4
  *
@@ -90,6 +90,6 @@ export declare class _BoxedSymbolDefinition implements BoxedSymbolDefinition {
90
90
  set prime(val: boolean | undefined);
91
91
  get composite(): boolean | undefined;
92
92
  set composite(val: boolean | undefined);
93
- updateFlags(flags: Partial<SymbolFlags>): void;
93
+ updateFlags(flags: Partial<NumericFlags>): void;
94
94
  }
95
- export declare function domainToFlags(dom: BoxedDomain | undefined | null): Partial<SymbolFlags>;
95
+ export declare function domainToFlags(dom: BoxedDomain | undefined | null): Partial<NumericFlags>;