@mojir/lits 2.1.10 → 2.1.12
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/cli/cli.js +219 -98
- package/dist/cli/reference/api.d.ts +3 -3
- package/dist/cli/reference/index.d.ts +4 -1
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/length.d.ts +1 -0
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/scale.d.ts +1 -1
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/subtract.d.ts +1 -1
- package/dist/cli/src/tokenizer/operators.d.ts +2 -2
- package/dist/cli/src/utils/index.d.ts +2 -1
- package/dist/index.esm.js +218 -97
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +218 -97
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +218 -97
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +3 -3
- package/dist/reference/index.d.ts +4 -1
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/length.d.ts +1 -0
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/scale.d.ts +1 -1
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/subtract.d.ts +1 -1
- package/dist/src/tokenizer/operators.d.ts +2 -2
- package/dist/src/utils/index.d.ts +2 -1
- package/dist/testFramework.esm.js +119 -73
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +119 -73
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.1.
|
|
95
|
+
var version = "2.1.12";
|
|
96
96
|
|
|
97
97
|
function getCodeMarker(sourceCodeInfo) {
|
|
98
98
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -824,7 +824,7 @@ function deepEqual(a, b, sourceCodeInfo) {
|
|
|
824
824
|
if (a === b)
|
|
825
825
|
return true;
|
|
826
826
|
if (typeof a === 'number' && typeof b === 'number')
|
|
827
|
-
return
|
|
827
|
+
return approxEqual(a, b);
|
|
828
828
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
829
829
|
if (a.length !== b.length)
|
|
830
830
|
return false;
|
|
@@ -913,9 +913,8 @@ function approxEqual(a, b, epsilon) {
|
|
|
913
913
|
// Use relative error for larger values
|
|
914
914
|
return diff / (absA + absB) < epsilon;
|
|
915
915
|
}
|
|
916
|
-
function approxZero(value
|
|
917
|
-
|
|
918
|
-
return Math.abs(value) < epsilon;
|
|
916
|
+
function approxZero(value) {
|
|
917
|
+
return Math.abs(value) < EPSILON;
|
|
919
918
|
}
|
|
920
919
|
|
|
921
920
|
// isArray not needed, use Array.isArary
|
|
@@ -2676,30 +2675,6 @@ var mathNormalExpression = {
|
|
|
2676
2675
|
},
|
|
2677
2676
|
paramCount: {},
|
|
2678
2677
|
},
|
|
2679
|
-
'~': {
|
|
2680
|
-
evaluate: function (params, sourceCodeInfo) {
|
|
2681
|
-
var _a;
|
|
2682
|
-
var _b = __read(getNumberVectorOrMatrixOperation([params[0], params[1]], sourceCodeInfo), 2), operation = _b[0], operands = _b[1];
|
|
2683
|
-
var eplsilon = (_a = params[2]) !== null && _a !== void 0 ? _a : 1e-10;
|
|
2684
|
-
assertNumber(eplsilon, sourceCodeInfo, { positive: true, finite: true });
|
|
2685
|
-
if (operation === 'number') {
|
|
2686
|
-
var _c = __read(operands, 2), first = _c[0], second = _c[1];
|
|
2687
|
-
return approxEqual(first, second, eplsilon);
|
|
2688
|
-
}
|
|
2689
|
-
else if (operation === 'vector') {
|
|
2690
|
-
var firstVector = operands[0];
|
|
2691
|
-
var secondVector_1 = operands[1];
|
|
2692
|
-
return firstVector.every(function (val, i) { return approxEqual(val, secondVector_1[i], eplsilon); });
|
|
2693
|
-
}
|
|
2694
|
-
else {
|
|
2695
|
-
var firstMatrix = operands[0];
|
|
2696
|
-
var secondMatrix_1 = operands[1];
|
|
2697
|
-
return firstMatrix.every(function (row, i) { return row.every(function (val, j) { return approxEqual(val, secondMatrix_1[i][j], eplsilon); }); });
|
|
2698
|
-
}
|
|
2699
|
-
},
|
|
2700
|
-
paramCount: { min: 2, max: 3 },
|
|
2701
|
-
aliases: ['≈'],
|
|
2702
|
-
},
|
|
2703
2678
|
'quot': {
|
|
2704
2679
|
evaluate: function (params, sourceCodeInfo) {
|
|
2705
2680
|
var _a = __read(getNumberVectorOrMatrixOperation(params, sourceCodeInfo), 2), operation = _a[0], operands = _a[1];
|
|
@@ -2708,13 +2683,13 @@ var mathNormalExpression = {
|
|
|
2708
2683
|
}
|
|
2709
2684
|
else if (operation === 'vector') {
|
|
2710
2685
|
var firstVector = operands[0];
|
|
2711
|
-
var
|
|
2712
|
-
return firstVector.map(function (val, i) { return Math.trunc(val /
|
|
2686
|
+
var secondVector_1 = operands[1];
|
|
2687
|
+
return firstVector.map(function (val, i) { return Math.trunc(val / secondVector_1[i]); });
|
|
2713
2688
|
}
|
|
2714
2689
|
else {
|
|
2715
2690
|
var firstMatrix = operands[0];
|
|
2716
|
-
var
|
|
2717
|
-
return firstMatrix.map(function (row, i) { return row.map(function (val, j) { return Math.trunc(val /
|
|
2691
|
+
var secondMatrix_1 = operands[1];
|
|
2692
|
+
return firstMatrix.map(function (row, i) { return row.map(function (val, j) { return Math.trunc(val / secondMatrix_1[i][j]); }); });
|
|
2718
2693
|
}
|
|
2719
2694
|
},
|
|
2720
2695
|
paramCount: 2,
|
|
@@ -2728,19 +2703,19 @@ var mathNormalExpression = {
|
|
|
2728
2703
|
}
|
|
2729
2704
|
else if (operation === 'vector') {
|
|
2730
2705
|
var firstVector = operands[0];
|
|
2731
|
-
var
|
|
2706
|
+
var secondVector_2 = operands[1];
|
|
2732
2707
|
return firstVector.map(function (dividend, i) {
|
|
2733
|
-
var divisor =
|
|
2708
|
+
var divisor = secondVector_2[i];
|
|
2734
2709
|
var quotient = Math.floor(dividend / divisor);
|
|
2735
2710
|
return dividend - divisor * quotient;
|
|
2736
2711
|
});
|
|
2737
2712
|
}
|
|
2738
2713
|
else {
|
|
2739
2714
|
var firstMatrix = operands[0];
|
|
2740
|
-
var
|
|
2715
|
+
var secondMatrix_2 = operands[1];
|
|
2741
2716
|
return firstMatrix.map(function (row, i) { return row.map(function (val, j) {
|
|
2742
|
-
var quotient = Math.floor(val /
|
|
2743
|
-
return val -
|
|
2717
|
+
var quotient = Math.floor(val / secondMatrix_2[i][j]);
|
|
2718
|
+
return val - secondMatrix_2[i][j] * quotient;
|
|
2744
2719
|
}); });
|
|
2745
2720
|
}
|
|
2746
2721
|
},
|
|
@@ -2754,13 +2729,13 @@ var mathNormalExpression = {
|
|
|
2754
2729
|
}
|
|
2755
2730
|
else if (operation === 'vector') {
|
|
2756
2731
|
var firstVector = operands[0];
|
|
2757
|
-
var
|
|
2758
|
-
return firstVector.map(function (dividend, i) { return dividend %
|
|
2732
|
+
var secondVector_3 = operands[1];
|
|
2733
|
+
return firstVector.map(function (dividend, i) { return dividend % secondVector_3[i]; });
|
|
2759
2734
|
}
|
|
2760
2735
|
else {
|
|
2761
2736
|
var firstMatrix = operands[0];
|
|
2762
|
-
var
|
|
2763
|
-
return firstMatrix.map(function (row, i) { return row.map(function (dividend, j) { return dividend %
|
|
2737
|
+
var secondMatrix_3 = operands[1];
|
|
2738
|
+
return firstMatrix.map(function (row, i) { return row.map(function (dividend, j) { return dividend % secondMatrix_3[i][j]; }); });
|
|
2764
2739
|
}
|
|
2765
2740
|
},
|
|
2766
2741
|
paramCount: 2,
|
|
@@ -2810,13 +2785,13 @@ var mathNormalExpression = {
|
|
|
2810
2785
|
}
|
|
2811
2786
|
else if (operation === 'vector') {
|
|
2812
2787
|
var firstVector = operands[0];
|
|
2813
|
-
var
|
|
2814
|
-
return firstVector.map(function (base, i) { return Math.pow(base,
|
|
2788
|
+
var secondVector_4 = operands[1];
|
|
2789
|
+
return firstVector.map(function (base, i) { return Math.pow(base, secondVector_4[i]); });
|
|
2815
2790
|
}
|
|
2816
2791
|
else {
|
|
2817
2792
|
var firstMatrix = operands[0];
|
|
2818
|
-
var
|
|
2819
|
-
return firstMatrix.map(function (row, i) { return row.map(function (base, j) { return Math.pow(base,
|
|
2793
|
+
var secondMatrix_4 = operands[1];
|
|
2794
|
+
return firstMatrix.map(function (row, i) { return row.map(function (base, j) { return Math.pow(base, secondMatrix_4[i][j]); }); });
|
|
2820
2795
|
}
|
|
2821
2796
|
},
|
|
2822
2797
|
paramCount: 2,
|
|
@@ -3228,6 +3203,40 @@ var mathNormalExpression = {
|
|
|
3228
3203
|
},
|
|
3229
3204
|
paramCount: 1,
|
|
3230
3205
|
},
|
|
3206
|
+
'to-rad': {
|
|
3207
|
+
evaluate: function (params, sourceCodeInfo) {
|
|
3208
|
+
var _a = __read(getNumberVectorOrMatrixOperation(params, sourceCodeInfo), 2), operation = _a[0], operands = _a[1];
|
|
3209
|
+
if (operation === 'number') {
|
|
3210
|
+
return (operands[0] * Math.PI) / 180;
|
|
3211
|
+
}
|
|
3212
|
+
else if (operation === 'vector') {
|
|
3213
|
+
var vector = operands[0];
|
|
3214
|
+
return vector.map(function (val) { return (val * Math.PI) / 180; });
|
|
3215
|
+
}
|
|
3216
|
+
else {
|
|
3217
|
+
var matrix = operands[0];
|
|
3218
|
+
return matrix.map(function (row) { return row.map(function (val) { return (val * Math.PI) / 180; }); });
|
|
3219
|
+
}
|
|
3220
|
+
},
|
|
3221
|
+
paramCount: 1,
|
|
3222
|
+
},
|
|
3223
|
+
'to-deg': {
|
|
3224
|
+
evaluate: function (params, sourceCodeInfo) {
|
|
3225
|
+
var _a = __read(getNumberVectorOrMatrixOperation(params, sourceCodeInfo), 2), operation = _a[0], operands = _a[1];
|
|
3226
|
+
if (operation === 'number') {
|
|
3227
|
+
return (operands[0] * 180) / Math.PI;
|
|
3228
|
+
}
|
|
3229
|
+
else if (operation === 'vector') {
|
|
3230
|
+
var vector = operands[0];
|
|
3231
|
+
return vector.map(function (val) { return (val * 180) / Math.PI; });
|
|
3232
|
+
}
|
|
3233
|
+
else {
|
|
3234
|
+
var matrix = operands[0];
|
|
3235
|
+
return matrix.map(function (row) { return row.map(function (val) { return (val * 180) / Math.PI; }); });
|
|
3236
|
+
}
|
|
3237
|
+
},
|
|
3238
|
+
paramCount: 1,
|
|
3239
|
+
},
|
|
3231
3240
|
};
|
|
3232
3241
|
|
|
3233
3242
|
function isEqual(_a, sourceCodeInfo) {
|
|
@@ -3847,9 +3856,9 @@ var predicatesNormalExpression = {
|
|
|
3847
3856
|
},
|
|
3848
3857
|
'zero?': {
|
|
3849
3858
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3850
|
-
var _b = __read(_a, 1),
|
|
3851
|
-
assertNumber(
|
|
3852
|
-
return
|
|
3859
|
+
var _b = __read(_a, 1), value = _b[0];
|
|
3860
|
+
assertNumber(value, sourceCodeInfo, { finite: true });
|
|
3861
|
+
return Math.abs(value) < EPSILON;
|
|
3853
3862
|
},
|
|
3854
3863
|
paramCount: 1,
|
|
3855
3864
|
},
|
|
@@ -6695,6 +6704,10 @@ function scale(vector, scalar) {
|
|
|
6695
6704
|
return vector.map(function (item) { return item * scalar; });
|
|
6696
6705
|
}
|
|
6697
6706
|
|
|
6707
|
+
function length(vector) {
|
|
6708
|
+
return Math.sqrt(vector.reduce(function (acc, item) { return acc + Math.pow(item, 2); }, 0));
|
|
6709
|
+
}
|
|
6710
|
+
|
|
6698
6711
|
var linearAlgebraNormalExpression = {
|
|
6699
6712
|
'lin:rotate2d': {
|
|
6700
6713
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -7019,7 +7032,7 @@ var linearAlgebraNormalExpression = {
|
|
|
7019
7032
|
evaluate: function (_a, sourceCodeInfo) {
|
|
7020
7033
|
var _b = __read(_a, 1), vector = _b[0];
|
|
7021
7034
|
assertNonEmptyVector(vector, sourceCodeInfo);
|
|
7022
|
-
return
|
|
7035
|
+
return length(vector);
|
|
7023
7036
|
},
|
|
7024
7037
|
paramCount: 1,
|
|
7025
7038
|
aliases: ['lin:l2-norm', 'lin:length'],
|
|
@@ -7325,6 +7338,31 @@ var linearAlgebraNormalExpression = {
|
|
|
7325
7338
|
},
|
|
7326
7339
|
paramCount: 2,
|
|
7327
7340
|
},
|
|
7341
|
+
'lin:to-polar': {
|
|
7342
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
7343
|
+
var _b = __read(_a, 1), vector = _b[0];
|
|
7344
|
+
assert2dVector(vector, sourceCodeInfo);
|
|
7345
|
+
if (isZeroVector(vector)) {
|
|
7346
|
+
return [0, 0];
|
|
7347
|
+
}
|
|
7348
|
+
var r = Math.sqrt(Math.pow(vector[0], 2) + Math.pow(vector[1], 2));
|
|
7349
|
+
var theta = Math.atan2(vector[1], vector[0]);
|
|
7350
|
+
return [r, theta];
|
|
7351
|
+
},
|
|
7352
|
+
paramCount: 1,
|
|
7353
|
+
},
|
|
7354
|
+
'lin:from-polar': {
|
|
7355
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
7356
|
+
var _b = __read(_a, 1), polar = _b[0];
|
|
7357
|
+
assert2dVector(polar, sourceCodeInfo);
|
|
7358
|
+
var _c = __read(polar, 2), r = _c[0], theta = _c[1];
|
|
7359
|
+
if (r === 0) {
|
|
7360
|
+
return [0, 0];
|
|
7361
|
+
}
|
|
7362
|
+
return [r * Math.cos(theta), r * Math.sin(theta)];
|
|
7363
|
+
},
|
|
7364
|
+
paramCount: 1,
|
|
7365
|
+
},
|
|
7328
7366
|
};
|
|
7329
7367
|
|
|
7330
7368
|
/**
|
|
@@ -12852,8 +12890,6 @@ var binaryOperators = [
|
|
|
12852
12890
|
'=', // equal
|
|
12853
12891
|
'!=', // not equal
|
|
12854
12892
|
'≠', // not equal
|
|
12855
|
-
'~', // approximate
|
|
12856
|
-
'≈', // approximate
|
|
12857
12893
|
'&', // bitwise AND
|
|
12858
12894
|
'xor', // bitwise XOR
|
|
12859
12895
|
'|', // bitwise OR
|
|
@@ -12863,6 +12899,8 @@ var binaryOperators = [
|
|
|
12863
12899
|
'|>', // pipe
|
|
12864
12900
|
];
|
|
12865
12901
|
var otherOperators = [
|
|
12902
|
+
'?', // conditional operator
|
|
12903
|
+
':', // conditional operator
|
|
12866
12904
|
'->', // lambda
|
|
12867
12905
|
'...', // rest
|
|
12868
12906
|
'.', // property accessor
|
|
@@ -12872,17 +12910,12 @@ var otherOperators = [
|
|
|
12872
12910
|
];
|
|
12873
12911
|
var symbolicOperators = __spreadArray(__spreadArray([], __read(binaryOperators), false), __read(otherOperators), false);
|
|
12874
12912
|
var nonFunctionOperators = [
|
|
12875
|
-
'??',
|
|
12876
|
-
'&&',
|
|
12877
|
-
'||',
|
|
12878
12913
|
'comment',
|
|
12879
12914
|
'cond',
|
|
12880
12915
|
'def',
|
|
12881
12916
|
'defined?',
|
|
12882
|
-
// 'defn',
|
|
12883
12917
|
'do',
|
|
12884
12918
|
'doseq',
|
|
12885
|
-
// 'fn',
|
|
12886
12919
|
'if',
|
|
12887
12920
|
'let',
|
|
12888
12921
|
'loop',
|
|
@@ -13460,8 +13493,9 @@ function untokenize(tokenStream) {
|
|
|
13460
13493
|
}, '');
|
|
13461
13494
|
}
|
|
13462
13495
|
|
|
13463
|
-
var exponentiationPrecedence =
|
|
13464
|
-
var binaryFunctionalOperatorPrecedence =
|
|
13496
|
+
var exponentiationPrecedence = 12;
|
|
13497
|
+
var binaryFunctionalOperatorPrecedence = 3;
|
|
13498
|
+
var conditionalOperatorPrecedence = 1;
|
|
13465
13499
|
var placeholderRegexp = /^\$([1-9]\d?)?$/;
|
|
13466
13500
|
function withSourceCodeInfo(node, sourceCodeInfo) {
|
|
13467
13501
|
if (sourceCodeInfo) {
|
|
@@ -13476,40 +13510,39 @@ function getPrecedence(operatorSign, sourceCodeInfo) {
|
|
|
13476
13510
|
case '*': // multiplication
|
|
13477
13511
|
case '/': // division
|
|
13478
13512
|
case '%': // remainder
|
|
13479
|
-
return
|
|
13513
|
+
return 11;
|
|
13480
13514
|
case '+': // addition
|
|
13481
13515
|
case '-': // subtraction
|
|
13482
|
-
return
|
|
13516
|
+
return 10;
|
|
13483
13517
|
case '<<': // left shift
|
|
13484
13518
|
case '>>': // signed right shift
|
|
13485
13519
|
case '>>>': // unsigned right shift
|
|
13486
|
-
return
|
|
13520
|
+
return 9;
|
|
13487
13521
|
case '++': // string concatenation
|
|
13488
|
-
return
|
|
13522
|
+
return 8;
|
|
13489
13523
|
case '<': // less than
|
|
13490
13524
|
case '<=': // less than or equal
|
|
13491
13525
|
case '≤': // less than or equal
|
|
13492
13526
|
case '>': // greater than
|
|
13493
13527
|
case '>=': // greater than or equal
|
|
13494
13528
|
case '≥': // greater than or equal
|
|
13495
|
-
return
|
|
13529
|
+
return 7;
|
|
13496
13530
|
case '=': // equal
|
|
13497
13531
|
case '!=': // not equal
|
|
13498
13532
|
case '≠': // not equal
|
|
13499
|
-
|
|
13500
|
-
case '≈': // approximate
|
|
13501
|
-
return 5;
|
|
13533
|
+
return 6;
|
|
13502
13534
|
case '&': // bitwise AND
|
|
13503
13535
|
case 'xor': // bitwise XOR
|
|
13504
13536
|
case '|': // bitwise OR
|
|
13505
|
-
return
|
|
13537
|
+
return 5;
|
|
13506
13538
|
case '&&': // logical AND
|
|
13507
13539
|
case '||': // logical OR
|
|
13508
13540
|
case '??': // nullish coalescing
|
|
13509
|
-
return
|
|
13541
|
+
return 4;
|
|
13542
|
+
// leave room for binaryFunctionalOperatorPrecedence = 3
|
|
13510
13543
|
case '|>': // pipe
|
|
13511
|
-
return
|
|
13512
|
-
// leave room for
|
|
13544
|
+
return 2;
|
|
13545
|
+
// leave room for conditionalOperatorPrecedence = 1
|
|
13513
13546
|
/* v8 ignore next 2 */
|
|
13514
13547
|
default:
|
|
13515
13548
|
throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
|
|
@@ -13551,21 +13584,21 @@ function fromBinaryOperatorToNode(operator, symbolNode, left, right, sourceCodeI
|
|
|
13551
13584
|
case '&':
|
|
13552
13585
|
case 'xor':
|
|
13553
13586
|
case '|':
|
|
13554
|
-
case '~':
|
|
13555
|
-
case '≈':
|
|
13556
13587
|
case '|>':
|
|
13557
13588
|
return createNamedNormalExpressionNode(symbolNode, [left, right], sourceCodeInfo);
|
|
13558
13589
|
case '&&':
|
|
13559
13590
|
case '||':
|
|
13560
13591
|
case '??':
|
|
13561
13592
|
return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes[operatorName], [left, right]]], sourceCodeInfo);
|
|
13562
|
-
/* v8 ignore next
|
|
13593
|
+
/* v8 ignore next 11 */
|
|
13563
13594
|
case '.':
|
|
13564
13595
|
case ';':
|
|
13565
13596
|
case ':=':
|
|
13566
13597
|
case ',':
|
|
13567
13598
|
case '->':
|
|
13568
13599
|
case '...':
|
|
13600
|
+
case '?':
|
|
13601
|
+
case ':':
|
|
13569
13602
|
throw new LitsError("Unknown binary operator: ".concat(operatorName), sourceCodeInfo);
|
|
13570
13603
|
default:
|
|
13571
13604
|
throw new LitsError("Unknown binary operator: ".concat(operatorName), sourceCodeInfo);
|
|
@@ -13681,6 +13714,19 @@ var Parser = /** @class */ (function () {
|
|
|
13681
13714
|
}
|
|
13682
13715
|
left = createNamedNormalExpressionNode(operatorSymbol, [left, right], operator[2]);
|
|
13683
13716
|
}
|
|
13717
|
+
else if ((operator === null || operator === void 0 ? void 0 : operator[1]) === '?') {
|
|
13718
|
+
if (conditionalOperatorPrecedence <= precedence) {
|
|
13719
|
+
break;
|
|
13720
|
+
}
|
|
13721
|
+
this.advance();
|
|
13722
|
+
var trueNode = this.parseExpression();
|
|
13723
|
+
if (!isOperatorToken(this.peek(), ':')) {
|
|
13724
|
+
throw new LitsError('Expected :', this.peekSourceCodeInfo());
|
|
13725
|
+
}
|
|
13726
|
+
this.advance();
|
|
13727
|
+
var falseNode = this.parseExpression();
|
|
13728
|
+
left = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [left, trueNode, falseNode]]], left[2]);
|
|
13729
|
+
}
|
|
13684
13730
|
else {
|
|
13685
13731
|
break;
|
|
13686
13732
|
}
|
|
@@ -15095,7 +15141,6 @@ var api = {
|
|
|
15095
15141
|
'-',
|
|
15096
15142
|
'*',
|
|
15097
15143
|
'/',
|
|
15098
|
-
'~',
|
|
15099
15144
|
'mod',
|
|
15100
15145
|
'rem',
|
|
15101
15146
|
'quot',
|
|
@@ -15127,6 +15172,8 @@ var api = {
|
|
|
15127
15172
|
'asinh',
|
|
15128
15173
|
'acosh',
|
|
15129
15174
|
'atanh',
|
|
15175
|
+
'to-rad',
|
|
15176
|
+
'to-deg',
|
|
15130
15177
|
],
|
|
15131
15178
|
functional: [
|
|
15132
15179
|
'|>',
|
|
@@ -15399,6 +15446,8 @@ var api = {
|
|
|
15399
15446
|
'lin:cross-correlation',
|
|
15400
15447
|
'lin:rref',
|
|
15401
15448
|
'lin:solve',
|
|
15449
|
+
'lin:to-polar',
|
|
15450
|
+
'lin:from-polar',
|
|
15402
15451
|
],
|
|
15403
15452
|
numberTheory: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(getNumberTheorySequenceNames('abundant')), false), __read(getNumberTheorySequenceNames('bell')), false), __read(getNumberTheorySequenceNames('catalan')), false), __read(getNumberTheorySequenceNames('composite')), false), __read(getNumberTheorySequenceNames('factorial')), false), __read(getNumberTheorySequenceNames('fibonacci')), false), __read(getNumberTheorySequenceNames('geometric')), false), __read(getNumberTheorySequenceNames('golomb')), false), __read(getNumberTheorySequenceNames('happy')), false), __read(getNumberTheorySequenceNames('look-and-say')), false), __read(getNumberTheorySequenceNames('lucas')), false), __read(getNumberTheorySequenceNames('lucky')), false), __read(getNumberTheorySequenceNames('mersenne')), false), __read(getNumberTheorySequenceNames('padovan')), false), __read(getNumberTheorySequenceNames('partition')), false), __read(getNumberTheorySequenceNames('pell')), false), __read(getNumberTheorySequenceNames('perfect')), false), __read(getNumberTheorySequenceNames('perfect-cube')), false), __read(getNumberTheorySequenceNames('perfect-power')), false), __read(getNumberTheorySequenceNames('perfect-square')), false), __read(getNumberTheorySequenceNames('polygonal')), false), __read(getNumberTheorySequenceNames('prime')), false), __read(getNumberTheorySequenceNames('recaman')), false), __read(getNumberTheorySequenceNames('sylvester')), false), __read(getNumberTheorySequenceNames('thue-morse')), false), __read(getNumberTheorySequenceNames('tribonacci')), false), [
|
|
15404
15453
|
'nth:collatz-seq',
|
|
@@ -17087,29 +17136,6 @@ var mathReference = {
|
|
|
17087
17136
|
'[[1, 2, 3], [4, 5, 6]] / 2',
|
|
17088
17137
|
],
|
|
17089
17138
|
},
|
|
17090
|
-
'~': {
|
|
17091
|
-
title: '~',
|
|
17092
|
-
category: 'Math',
|
|
17093
|
-
linkName: '-tilde',
|
|
17094
|
-
returns: {
|
|
17095
|
-
type: ['number', 'vector', 'matrix'],
|
|
17096
|
-
},
|
|
17097
|
-
args: __assign({}, mixedOperatorArgs),
|
|
17098
|
-
variants: [
|
|
17099
|
-
{ argumentNames: ['a, b'] },
|
|
17100
|
-
],
|
|
17101
|
-
description: 'The `~` checks for approximately equal values, returning `true` if the absolute difference between the two numbers is less than or equal to a small threshold (default: `1e-10`). It works on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it checks each element for approximate equality.',
|
|
17102
|
-
examples: [
|
|
17103
|
-
'~(0.1, 0.1)',
|
|
17104
|
-
'~(0.1, 0.10000000000001)',
|
|
17105
|
-
'~(0.1, 0.2)',
|
|
17106
|
-
'~(0.1, 0.101, 0.1)',
|
|
17107
|
-
'~([1, 2, 3], [1.00000000000001, 2.00000000000001, 3.00000000000001])',
|
|
17108
|
-
'~([1, 2, 3], [1.1, 2.1, 3.1])',
|
|
17109
|
-
'~([[1, 2, 3], [1, 2, 3]], [[1.01, 2.01, 3.01], [1.01, 2.01, 3.01]], 0.1)',
|
|
17110
|
-
],
|
|
17111
|
-
aliases: ['≈'],
|
|
17112
|
-
},
|
|
17113
17139
|
'mod': {
|
|
17114
17140
|
title: 'mod',
|
|
17115
17141
|
category: 'Math',
|
|
@@ -17887,6 +17913,56 @@ var mathReference = {
|
|
|
17887
17913
|
'atanh([[0.1, 0.2], [0.3, 0.4]])',
|
|
17888
17914
|
],
|
|
17889
17915
|
},
|
|
17916
|
+
'to-rad': {
|
|
17917
|
+
title: 'to-rad',
|
|
17918
|
+
category: 'Math',
|
|
17919
|
+
linkName: 'to-rad',
|
|
17920
|
+
returns: {
|
|
17921
|
+
type: ['number', 'vector', 'matrix'],
|
|
17922
|
+
},
|
|
17923
|
+
args: {
|
|
17924
|
+
x: {
|
|
17925
|
+
type: ['number', 'vector', 'matrix'],
|
|
17926
|
+
},
|
|
17927
|
+
},
|
|
17928
|
+
variants: [
|
|
17929
|
+
{ argumentNames: ['x'] },
|
|
17930
|
+
],
|
|
17931
|
+
description: 'The `to-rad` function converts an angle from degrees to radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.',
|
|
17932
|
+
examples: [
|
|
17933
|
+
'to-rad(0)',
|
|
17934
|
+
'to-rad(90)',
|
|
17935
|
+
'to-rad(180)',
|
|
17936
|
+
'to-rad(360)',
|
|
17937
|
+
'to-rad([0, 90, 180])',
|
|
17938
|
+
'to-rad([[0, 90], [180, 360]])',
|
|
17939
|
+
],
|
|
17940
|
+
},
|
|
17941
|
+
'to-deg': {
|
|
17942
|
+
title: 'to-deg',
|
|
17943
|
+
category: 'Math',
|
|
17944
|
+
linkName: 'to-deg',
|
|
17945
|
+
returns: {
|
|
17946
|
+
type: ['number', 'vector', 'matrix'],
|
|
17947
|
+
},
|
|
17948
|
+
args: {
|
|
17949
|
+
x: {
|
|
17950
|
+
type: ['number', 'vector', 'matrix'],
|
|
17951
|
+
},
|
|
17952
|
+
},
|
|
17953
|
+
variants: [
|
|
17954
|
+
{ argumentNames: ['x'] },
|
|
17955
|
+
],
|
|
17956
|
+
description: 'The `to-deg` function converts an angle from radians to degrees, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.',
|
|
17957
|
+
examples: [
|
|
17958
|
+
'to-deg(0)',
|
|
17959
|
+
'to-deg(PI)',
|
|
17960
|
+
'to-deg(PI / 2)',
|
|
17961
|
+
'to-deg(3 * PI / 2)',
|
|
17962
|
+
'to-deg([0, PI, PI / 2])',
|
|
17963
|
+
'to-deg([[0, PI], [PI / 2, 3 * PI / 2]])',
|
|
17964
|
+
],
|
|
17965
|
+
},
|
|
17890
17966
|
};
|
|
17891
17967
|
|
|
17892
17968
|
var miscReference = {
|
|
@@ -24340,6 +24416,51 @@ var linAlgReference = {
|
|
|
24340
24416
|
'lin:solve([[2, 3], [1, -1]], [8, 2])',
|
|
24341
24417
|
],
|
|
24342
24418
|
},
|
|
24419
|
+
'lin:to-polar': {
|
|
24420
|
+
title: 'lin:to-polar',
|
|
24421
|
+
category: 'Linear Algebra',
|
|
24422
|
+
description: 'Converts a 2D vector to polar coordinates.',
|
|
24423
|
+
linkName: 'lin-colon-to-polar',
|
|
24424
|
+
returns: {
|
|
24425
|
+
type: 'vector',
|
|
24426
|
+
},
|
|
24427
|
+
args: {
|
|
24428
|
+
vector: {
|
|
24429
|
+
type: 'vector',
|
|
24430
|
+
description: '2D Vector to convert.',
|
|
24431
|
+
},
|
|
24432
|
+
},
|
|
24433
|
+
variants: [
|
|
24434
|
+
{ argumentNames: ['vector'] },
|
|
24435
|
+
],
|
|
24436
|
+
examples: [
|
|
24437
|
+
'lin:to-polar([1, 2])',
|
|
24438
|
+
'lin:to-polar([3, 4])',
|
|
24439
|
+
],
|
|
24440
|
+
},
|
|
24441
|
+
'lin:from-polar': {
|
|
24442
|
+
title: 'lin:from-polar',
|
|
24443
|
+
category: 'Linear Algebra',
|
|
24444
|
+
description: 'Converts polar coordinates to a 2D vector.',
|
|
24445
|
+
linkName: 'lin-colon-from-polar',
|
|
24446
|
+
returns: {
|
|
24447
|
+
type: 'vector',
|
|
24448
|
+
},
|
|
24449
|
+
args: {
|
|
24450
|
+
polar: {
|
|
24451
|
+
type: 'vector',
|
|
24452
|
+
description: 'Polar coordinates to convert.',
|
|
24453
|
+
},
|
|
24454
|
+
},
|
|
24455
|
+
variants: [
|
|
24456
|
+
{ argumentNames: ['polar'] },
|
|
24457
|
+
],
|
|
24458
|
+
examples: [
|
|
24459
|
+
'lin:from-polar([1, PI / 4])',
|
|
24460
|
+
'lin:from-polar([1, 0])',
|
|
24461
|
+
'lin:from-polar([1, -PI / 2])',
|
|
24462
|
+
],
|
|
24463
|
+
},
|
|
24343
24464
|
};
|
|
24344
24465
|
|
|
24345
24466
|
var predicateReference = {
|