@cortex-js/compute-engine 0.19.0 → 0.19.1
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/dist/compute-engine.esm.js +185 -119
- package/dist/compute-engine.js +185 -119
- package/dist/compute-engine.min.esm.js +9 -9
- package/dist/compute-engine.min.js +9 -9
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +3 -2
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +1 -1
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.19.
|
|
1
|
+
/** CortexJS Compute Engine 0.19.1 */
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -12276,90 +12276,6 @@ function gamma(z) {
|
|
|
12276
12276
|
const t = z + gammaG + 0.5;
|
|
12277
12277
|
return Math.sqrt(2 * Math.PI) * Math.pow(t, z + 0.5) * Math.exp(-t) * x;
|
|
12278
12278
|
}
|
|
12279
|
-
function fromDigits(s, base = 10) {
|
|
12280
|
-
let value = 0;
|
|
12281
|
-
for (let i = 0; i < s.length; i++) {
|
|
12282
|
-
const k = {
|
|
12283
|
-
" ": -1,
|
|
12284
|
-
"\xA0": -1,
|
|
12285
|
-
// NBS
|
|
12286
|
-
"\u2000": -1,
|
|
12287
|
-
// EN QUAD
|
|
12288
|
-
"\u2001": -1,
|
|
12289
|
-
// EM QUAD
|
|
12290
|
-
"\u2002": -1,
|
|
12291
|
-
// EN SPACE
|
|
12292
|
-
"\u2003": -1,
|
|
12293
|
-
// EM SPACE
|
|
12294
|
-
"\u2004": -1,
|
|
12295
|
-
// THREE-PER-EM SPACE
|
|
12296
|
-
"\u2005": -1,
|
|
12297
|
-
// FOUR-PER-EM SPACE
|
|
12298
|
-
"\u2006": -1,
|
|
12299
|
-
// SIX-PER-EM SPACE
|
|
12300
|
-
"\u2007": -1,
|
|
12301
|
-
// FIGURE SPACE
|
|
12302
|
-
"\u2008": -1,
|
|
12303
|
-
// PUNCTUATION SPACE
|
|
12304
|
-
"\u2009": -1,
|
|
12305
|
-
// THIN SPACE
|
|
12306
|
-
"\u200A": -1,
|
|
12307
|
-
// HAIR SPACE
|
|
12308
|
-
"\u200B": -1,
|
|
12309
|
-
// ZWS
|
|
12310
|
-
"\u202F": -1,
|
|
12311
|
-
// NARROW NBS
|
|
12312
|
-
"\u205F": -1,
|
|
12313
|
-
// MEDIUM MATHEMATICAL SPACE
|
|
12314
|
-
"_": -1,
|
|
12315
|
-
",": -1,
|
|
12316
|
-
"0": 0,
|
|
12317
|
-
"1": 1,
|
|
12318
|
-
"2": 2,
|
|
12319
|
-
"3": 3,
|
|
12320
|
-
"4": 4,
|
|
12321
|
-
"5": 5,
|
|
12322
|
-
"6": 6,
|
|
12323
|
-
"7": 7,
|
|
12324
|
-
"8": 8,
|
|
12325
|
-
"9": 9,
|
|
12326
|
-
"a": 10,
|
|
12327
|
-
"b": 11,
|
|
12328
|
-
"c": 12,
|
|
12329
|
-
"d": 13,
|
|
12330
|
-
"e": 14,
|
|
12331
|
-
"f": 15,
|
|
12332
|
-
"g": 16,
|
|
12333
|
-
"h": 17,
|
|
12334
|
-
"i": 18,
|
|
12335
|
-
"j": 19,
|
|
12336
|
-
"k": 20,
|
|
12337
|
-
"l": 21,
|
|
12338
|
-
"m": 22,
|
|
12339
|
-
"n": 23,
|
|
12340
|
-
"o": 24,
|
|
12341
|
-
"p": 25,
|
|
12342
|
-
"q": 26,
|
|
12343
|
-
"r": 27,
|
|
12344
|
-
"s": 28,
|
|
12345
|
-
"t": 29,
|
|
12346
|
-
"u": 30,
|
|
12347
|
-
"v": 31,
|
|
12348
|
-
"w": 32,
|
|
12349
|
-
"x": 33,
|
|
12350
|
-
"y": 34,
|
|
12351
|
-
"z": 35
|
|
12352
|
-
}[s[i]];
|
|
12353
|
-
if (k !== -1) {
|
|
12354
|
-
if (k === void 0)
|
|
12355
|
-
return [value, s.substring(i)];
|
|
12356
|
-
if (k >= base)
|
|
12357
|
-
return [value, s.substring(i)];
|
|
12358
|
-
value = value * base + k;
|
|
12359
|
-
}
|
|
12360
|
-
}
|
|
12361
|
-
return [value, ""];
|
|
12362
|
-
}
|
|
12363
12279
|
function asFloat(expr) {
|
|
12364
12280
|
if (expr === void 0 || expr === null)
|
|
12365
12281
|
return null;
|
|
@@ -12510,6 +12426,148 @@ function limit(f, x, dir = 1) {
|
|
|
12510
12426
|
const [val, err] = extrapolate(f, x, { step: dir > 0 ? 1 : -1 });
|
|
12511
12427
|
return val;
|
|
12512
12428
|
}
|
|
12429
|
+
function fromRoman(roman) {
|
|
12430
|
+
if (roman === "N")
|
|
12431
|
+
return [0, ""];
|
|
12432
|
+
const romanMap = {
|
|
12433
|
+
I: 1,
|
|
12434
|
+
V: 5,
|
|
12435
|
+
X: 10,
|
|
12436
|
+
L: 50,
|
|
12437
|
+
C: 100,
|
|
12438
|
+
D: 500,
|
|
12439
|
+
M: 1e3
|
|
12440
|
+
};
|
|
12441
|
+
let total = 0;
|
|
12442
|
+
let prevValue = 0;
|
|
12443
|
+
roman = roman.toUpperCase();
|
|
12444
|
+
for (let i = roman.length - 1; i >= 0; i--) {
|
|
12445
|
+
const currentValue = romanMap[roman[i]];
|
|
12446
|
+
if (currentValue === void 0)
|
|
12447
|
+
return [total, roman.slice(i)];
|
|
12448
|
+
if (currentValue < prevValue)
|
|
12449
|
+
total -= currentValue;
|
|
12450
|
+
else
|
|
12451
|
+
total += currentValue;
|
|
12452
|
+
prevValue = currentValue;
|
|
12453
|
+
}
|
|
12454
|
+
return [total, ""];
|
|
12455
|
+
}
|
|
12456
|
+
function fromDigits(s, baseInput) {
|
|
12457
|
+
s = s.trim();
|
|
12458
|
+
if (s.length === 0)
|
|
12459
|
+
return [NaN, ""];
|
|
12460
|
+
if (s.startsWith("+"))
|
|
12461
|
+
return fromDigits(s.slice(1), baseInput);
|
|
12462
|
+
if (s.startsWith("-")) {
|
|
12463
|
+
const [v, r] = fromDigits(s.slice(1), baseInput);
|
|
12464
|
+
return [-v, r];
|
|
12465
|
+
}
|
|
12466
|
+
let base = 10;
|
|
12467
|
+
if (typeof baseInput === "string")
|
|
12468
|
+
baseInput = baseInput.toLowerCase();
|
|
12469
|
+
if (s.startsWith("0x")) {
|
|
12470
|
+
base = 16;
|
|
12471
|
+
s = s.slice(2);
|
|
12472
|
+
} else if (s.startsWith("0b")) {
|
|
12473
|
+
base = 2;
|
|
12474
|
+
s = s.slice(2);
|
|
12475
|
+
} else if (baseInput === "roman") {
|
|
12476
|
+
return fromRoman(s);
|
|
12477
|
+
} else if (baseInput === "base64" || baseInput === "base-64") {
|
|
12478
|
+
try {
|
|
12479
|
+
return [parseInt(btoa(s)), ""];
|
|
12480
|
+
} catch (e) {
|
|
12481
|
+
return [NaN, ""];
|
|
12482
|
+
}
|
|
12483
|
+
} else if (typeof baseInput === "number") {
|
|
12484
|
+
base = baseInput;
|
|
12485
|
+
} else if (typeof baseInput === "string") {
|
|
12486
|
+
base = parseInt(baseInput);
|
|
12487
|
+
}
|
|
12488
|
+
let value = 0;
|
|
12489
|
+
for (let i = 0; i < s.length; i++) {
|
|
12490
|
+
const k = {
|
|
12491
|
+
" ": -1,
|
|
12492
|
+
"\xA0": -1,
|
|
12493
|
+
// NBS
|
|
12494
|
+
"\u2000": -1,
|
|
12495
|
+
// EN QUAD
|
|
12496
|
+
"\u2001": -1,
|
|
12497
|
+
// EM QUAD
|
|
12498
|
+
"\u2002": -1,
|
|
12499
|
+
// EN SPACE
|
|
12500
|
+
"\u2003": -1,
|
|
12501
|
+
// EM SPACE
|
|
12502
|
+
"\u2004": -1,
|
|
12503
|
+
// THREE-PER-EM SPACE
|
|
12504
|
+
"\u2005": -1,
|
|
12505
|
+
// FOUR-PER-EM SPACE
|
|
12506
|
+
"\u2006": -1,
|
|
12507
|
+
// SIX-PER-EM SPACE
|
|
12508
|
+
"\u2007": -1,
|
|
12509
|
+
// FIGURE SPACE
|
|
12510
|
+
"\u2008": -1,
|
|
12511
|
+
// PUNCTUATION SPACE
|
|
12512
|
+
"\u2009": -1,
|
|
12513
|
+
// THIN SPACE
|
|
12514
|
+
"\u200A": -1,
|
|
12515
|
+
// HAIR SPACE
|
|
12516
|
+
"\u200B": -1,
|
|
12517
|
+
// ZWS
|
|
12518
|
+
"\u202F": -1,
|
|
12519
|
+
// NARROW NBS
|
|
12520
|
+
"\u205F": -1,
|
|
12521
|
+
// MEDIUM MATHEMATICAL SPACE
|
|
12522
|
+
"_": -1,
|
|
12523
|
+
",": -1,
|
|
12524
|
+
"0": 0,
|
|
12525
|
+
"1": 1,
|
|
12526
|
+
"2": 2,
|
|
12527
|
+
"3": 3,
|
|
12528
|
+
"4": 4,
|
|
12529
|
+
"5": 5,
|
|
12530
|
+
"6": 6,
|
|
12531
|
+
"7": 7,
|
|
12532
|
+
"8": 8,
|
|
12533
|
+
"9": 9,
|
|
12534
|
+
"a": 10,
|
|
12535
|
+
"b": 11,
|
|
12536
|
+
"c": 12,
|
|
12537
|
+
"d": 13,
|
|
12538
|
+
"e": 14,
|
|
12539
|
+
"f": 15,
|
|
12540
|
+
"g": 16,
|
|
12541
|
+
"h": 17,
|
|
12542
|
+
"i": 18,
|
|
12543
|
+
"j": 19,
|
|
12544
|
+
"k": 20,
|
|
12545
|
+
"l": 21,
|
|
12546
|
+
"m": 22,
|
|
12547
|
+
"n": 23,
|
|
12548
|
+
"o": 24,
|
|
12549
|
+
"p": 25,
|
|
12550
|
+
"q": 26,
|
|
12551
|
+
"r": 27,
|
|
12552
|
+
"s": 28,
|
|
12553
|
+
"t": 29,
|
|
12554
|
+
"u": 30,
|
|
12555
|
+
"v": 31,
|
|
12556
|
+
"w": 32,
|
|
12557
|
+
"x": 33,
|
|
12558
|
+
"y": 34,
|
|
12559
|
+
"z": 35
|
|
12560
|
+
}[s[i]];
|
|
12561
|
+
if (k !== -1) {
|
|
12562
|
+
if (k === void 0)
|
|
12563
|
+
return [value, s.substring(i)];
|
|
12564
|
+
if (k >= base)
|
|
12565
|
+
return [value, s.substring(i)];
|
|
12566
|
+
value = value * base + k;
|
|
12567
|
+
}
|
|
12568
|
+
}
|
|
12569
|
+
return [value, ""];
|
|
12570
|
+
}
|
|
12513
12571
|
|
|
12514
12572
|
// src/compute-engine/numerics/numeric-bigint.ts
|
|
12515
12573
|
function bigint(a) {
|
|
@@ -20696,23 +20754,24 @@ var ARITHMETIC_LIBRARY = [
|
|
|
20696
20754
|
// @todo could accept `0xcafe`, `0b01010` or `(deadbeef)_16` as string formats
|
|
20697
20755
|
// @todo could accept "roman"... as base
|
|
20698
20756
|
// @todo could accept optional third parameter as the (padded) length of the output
|
|
20699
|
-
threadable: true,
|
|
20700
20757
|
signature: {
|
|
20701
|
-
domain: ["FunctionOf", "Strings", ["OptArg", "
|
|
20758
|
+
domain: ["FunctionOf", "Strings", ["OptArg", "Anything"], "Integers"],
|
|
20702
20759
|
evaluate: (ce, ops2) => {
|
|
20703
|
-
|
|
20704
|
-
if (!op12
|
|
20705
|
-
return ce.domainError("Strings",
|
|
20706
|
-
|
|
20760
|
+
let op12 = ops2[0]?.string;
|
|
20761
|
+
if (!op12)
|
|
20762
|
+
return ce.domainError("Strings", ops2[0]?.domain, ops2[0]);
|
|
20763
|
+
op12 = op12.trim();
|
|
20764
|
+
if (op12.startsWith("0x"))
|
|
20765
|
+
return ce.number(parseInt(op12.slice(2), 16));
|
|
20766
|
+
if (op12.startsWith("0b"))
|
|
20767
|
+
return ce.number(parseInt(op12.slice(2), 2));
|
|
20768
|
+
const op22 = ops2[1] ?? ce.Nothing;
|
|
20707
20769
|
if (op22.isNothing)
|
|
20708
|
-
return ce.number(Number.parseInt(op12
|
|
20709
|
-
if (op22.numericValue === null) {
|
|
20710
|
-
return ce.error(["unexpected-base", op22.latex], op22);
|
|
20711
|
-
}
|
|
20770
|
+
return ce.number(Number.parseInt(op12, 10));
|
|
20712
20771
|
const base = asFloat(op22);
|
|
20713
|
-
if (!Number.isInteger(base) || base < 2 || base > 36)
|
|
20772
|
+
if (base && (!Number.isInteger(base) || base < 2 || base > 36))
|
|
20714
20773
|
return ce.error(["unexpected-base", base], op22);
|
|
20715
|
-
const [value, rest] = fromDigits(op12.string
|
|
20774
|
+
const [value, rest] = fromDigits(op12, op22.string ?? op22.symbol ?? 10);
|
|
20716
20775
|
if (rest)
|
|
20717
20776
|
return ce.error(["unexpected-digit", { str: rest[0] }], {
|
|
20718
20777
|
str: rest
|
|
@@ -20734,7 +20793,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
20734
20793
|
const val = asFloat(op12) ?? NaN;
|
|
20735
20794
|
if (Number.isNaN(val) || !Number.isInteger(val))
|
|
20736
20795
|
return ce.domainError("Integers", op12.domain, op12);
|
|
20737
|
-
const op22 = ops2[1];
|
|
20796
|
+
const op22 = ops2[1] ?? ce.Nothing;
|
|
20738
20797
|
if (op22.isNothing) {
|
|
20739
20798
|
const op1Num = op12.numericValue;
|
|
20740
20799
|
if (typeof op1Num === "number")
|
|
@@ -27413,19 +27472,19 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
27413
27472
|
if (symDef) {
|
|
27414
27473
|
if (symDef.constant)
|
|
27415
27474
|
throw Error(`Cannot assign a value to the constant "${id}"`);
|
|
27416
|
-
if (
|
|
27417
|
-
throw Error(`The symbol "${id}" is not a function`);
|
|
27418
|
-
if (typeof value === "function")
|
|
27475
|
+
if (!symDef.inferredDomain && isFunctionValue(value))
|
|
27419
27476
|
throw Error(`Cannot assign a function to symbol "${id}"`);
|
|
27420
|
-
if (value === void 0 || value === null) {
|
|
27421
|
-
symDef.value = void 0;
|
|
27422
|
-
return this;
|
|
27423
|
-
}
|
|
27424
27477
|
const scope = symDef.scope;
|
|
27425
27478
|
scope?.ids?.delete(symDef.name);
|
|
27426
|
-
|
|
27427
|
-
|
|
27428
|
-
|
|
27479
|
+
if (!args && !isFunctionValue(value)) {
|
|
27480
|
+
if (value === void 0 || value === null) {
|
|
27481
|
+
symDef.value = void 0;
|
|
27482
|
+
return this;
|
|
27483
|
+
}
|
|
27484
|
+
symDef.value = this.box(value);
|
|
27485
|
+
scope?.ids?.set(symDef.name, symDef);
|
|
27486
|
+
return this;
|
|
27487
|
+
}
|
|
27429
27488
|
}
|
|
27430
27489
|
const fnDef = this.lookupFunction(id);
|
|
27431
27490
|
if (fnDef) {
|
|
@@ -27435,17 +27494,15 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
27435
27494
|
return this;
|
|
27436
27495
|
if (typeof value === "function") {
|
|
27437
27496
|
const previousScope2 = this.swapScope(scope);
|
|
27438
|
-
this.defineFunction(id, {
|
|
27439
|
-
signature: { evaluate: value }
|
|
27440
|
-
});
|
|
27497
|
+
this.defineFunction(id, { signature: { evaluate: value } });
|
|
27441
27498
|
this.swapScope(previousScope2);
|
|
27442
27499
|
return this;
|
|
27443
27500
|
}
|
|
27501
|
+
if (args && isFunctionValue(value))
|
|
27502
|
+
throw Error(`Unexpected arguments for "${id}"`);
|
|
27444
27503
|
const val = args ? this.box(["Function", value, ...args]) : this.box(value);
|
|
27445
27504
|
const previousScope = this.swapScope(scope);
|
|
27446
|
-
this.defineFunction(id, {
|
|
27447
|
-
signature: { evaluate: val }
|
|
27448
|
-
});
|
|
27505
|
+
this.defineFunction(id, { signature: { evaluate: val } });
|
|
27449
27506
|
this.swapScope(previousScope);
|
|
27450
27507
|
return this;
|
|
27451
27508
|
}
|
|
@@ -27454,9 +27511,11 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
27454
27511
|
return this;
|
|
27455
27512
|
}
|
|
27456
27513
|
if (typeof value === "function") {
|
|
27457
|
-
this.defineFunction(id, {
|
|
27458
|
-
|
|
27459
|
-
|
|
27514
|
+
this.defineFunction(id, { signature: { evaluate: value } });
|
|
27515
|
+
return this;
|
|
27516
|
+
}
|
|
27517
|
+
if (value instanceof _BoxedExpression && value.domain?.base === "Functions") {
|
|
27518
|
+
this.defineFunction(id, { signature: { evaluate: value } });
|
|
27460
27519
|
return this;
|
|
27461
27520
|
}
|
|
27462
27521
|
if (Array.isArray(value) || value instanceof _BoxedExpression || args) {
|
|
@@ -28046,12 +28105,19 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
28046
28105
|
}
|
|
28047
28106
|
}
|
|
28048
28107
|
};
|
|
28108
|
+
function isFunctionValue(value) {
|
|
28109
|
+
if (typeof value === "function")
|
|
28110
|
+
return true;
|
|
28111
|
+
if (value instanceof _BoxedExpression && value.domain?.base === "Functions")
|
|
28112
|
+
return true;
|
|
28113
|
+
return false;
|
|
28114
|
+
}
|
|
28049
28115
|
|
|
28050
28116
|
// src/compute-engine.ts
|
|
28051
|
-
var version = "0.19.
|
|
28117
|
+
var version = "0.19.1";
|
|
28052
28118
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
28053
28119
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
28054
|
-
version: "0.19.
|
|
28120
|
+
version: "0.19.1"
|
|
28055
28121
|
};
|
|
28056
28122
|
export {
|
|
28057
28123
|
ADDITION_PRECEDENCE,
|