@mojir/lits 2.1.12 → 2.1.14
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 +461 -58
- package/dist/cli/reference/api.d.ts +4 -4
- package/dist/cli/reference/index.d.ts +7 -1
- package/dist/index.esm.js +423 -52
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +423 -52
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +423 -52
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +4 -4
- package/dist/reference/index.d.ts +7 -1
- package/dist/testFramework.esm.js +212 -20
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +212 -20
- package/dist/testFramework.js.map +1 -1
- package/package.json +2 -2
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.14";
|
|
96
96
|
|
|
97
97
|
function getCodeMarker(sourceCodeInfo) {
|
|
98
98
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -453,6 +453,8 @@ function isNumber(value, options) {
|
|
|
453
453
|
if (options === void 0) { options = {}; }
|
|
454
454
|
if (typeof value !== 'number')
|
|
455
455
|
return false;
|
|
456
|
+
if (Number.isNaN(value))
|
|
457
|
+
return false;
|
|
456
458
|
if (options.integer && !Number.isInteger(value))
|
|
457
459
|
return false;
|
|
458
460
|
if (options.finite && !Number.isFinite(value))
|
|
@@ -1088,6 +1090,35 @@ var collectionNormalExpression = {
|
|
|
1088
1090
|
},
|
|
1089
1091
|
paramCount: 2,
|
|
1090
1092
|
},
|
|
1093
|
+
'filteri': {
|
|
1094
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1095
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1096
|
+
var executeFunction = _b.executeFunction;
|
|
1097
|
+
assertColl(coll, sourceCodeInfo);
|
|
1098
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1099
|
+
if (Array.isArray(coll)) {
|
|
1100
|
+
var result = coll.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1101
|
+
return result;
|
|
1102
|
+
}
|
|
1103
|
+
if (isString(coll)) {
|
|
1104
|
+
return coll
|
|
1105
|
+
.split('')
|
|
1106
|
+
.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1107
|
+
.join('');
|
|
1108
|
+
}
|
|
1109
|
+
return Object.entries(coll)
|
|
1110
|
+
.filter(function (_a) {
|
|
1111
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1112
|
+
return executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1113
|
+
})
|
|
1114
|
+
.reduce(function (result, _a) {
|
|
1115
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1116
|
+
result[key] = value;
|
|
1117
|
+
return result;
|
|
1118
|
+
}, {});
|
|
1119
|
+
},
|
|
1120
|
+
paramCount: 2,
|
|
1121
|
+
},
|
|
1091
1122
|
'map': {
|
|
1092
1123
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1093
1124
|
var executeFunction = _a.executeFunction;
|
|
@@ -1130,6 +1161,30 @@ var collectionNormalExpression = {
|
|
|
1130
1161
|
},
|
|
1131
1162
|
paramCount: { min: 2 },
|
|
1132
1163
|
},
|
|
1164
|
+
'mapi': {
|
|
1165
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1166
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1167
|
+
var executeFunction = _b.executeFunction;
|
|
1168
|
+
assertColl(coll, sourceCodeInfo);
|
|
1169
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1170
|
+
if (Array.isArray(coll)) {
|
|
1171
|
+
return coll.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1172
|
+
}
|
|
1173
|
+
if (isString(coll)) {
|
|
1174
|
+
return coll
|
|
1175
|
+
.split('')
|
|
1176
|
+
.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1177
|
+
.join('');
|
|
1178
|
+
}
|
|
1179
|
+
return Object.entries(coll)
|
|
1180
|
+
.reduce(function (acc, _a) {
|
|
1181
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1182
|
+
acc[key] = executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1183
|
+
return acc;
|
|
1184
|
+
}, {});
|
|
1185
|
+
},
|
|
1186
|
+
paramCount: 2,
|
|
1187
|
+
},
|
|
1133
1188
|
'reduce': {
|
|
1134
1189
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1135
1190
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1163,6 +1218,39 @@ var collectionNormalExpression = {
|
|
|
1163
1218
|
},
|
|
1164
1219
|
paramCount: 3,
|
|
1165
1220
|
},
|
|
1221
|
+
'reducei': {
|
|
1222
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1223
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1224
|
+
var executeFunction = _b.executeFunction;
|
|
1225
|
+
assertColl(coll, sourceCodeInfo);
|
|
1226
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1227
|
+
assertAny(initial, sourceCodeInfo);
|
|
1228
|
+
if (typeof coll === 'string') {
|
|
1229
|
+
assertString(initial, sourceCodeInfo);
|
|
1230
|
+
if (coll.length === 0)
|
|
1231
|
+
return initial;
|
|
1232
|
+
return coll.split('').reduce(function (result, elem, index) {
|
|
1233
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1234
|
+
}, initial);
|
|
1235
|
+
}
|
|
1236
|
+
else if (Array.isArray(coll)) {
|
|
1237
|
+
if (coll.length === 0)
|
|
1238
|
+
return initial;
|
|
1239
|
+
return coll.reduce(function (result, elem, index) {
|
|
1240
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1241
|
+
}, initial);
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
if (Object.keys(coll).length === 0)
|
|
1245
|
+
return initial;
|
|
1246
|
+
return Object.entries(coll).reduce(function (result, _a) {
|
|
1247
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1248
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1249
|
+
}, initial);
|
|
1250
|
+
}
|
|
1251
|
+
},
|
|
1252
|
+
paramCount: 3,
|
|
1253
|
+
},
|
|
1166
1254
|
'reduce-right': {
|
|
1167
1255
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1168
1256
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1195,6 +1283,38 @@ var collectionNormalExpression = {
|
|
|
1195
1283
|
},
|
|
1196
1284
|
paramCount: 3,
|
|
1197
1285
|
},
|
|
1286
|
+
'reducei-right': {
|
|
1287
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1288
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1289
|
+
var executeFunction = _b.executeFunction;
|
|
1290
|
+
assertColl(coll, sourceCodeInfo);
|
|
1291
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1292
|
+
assertAny(initial, sourceCodeInfo);
|
|
1293
|
+
if (typeof coll === 'string') {
|
|
1294
|
+
if (coll.length === 0)
|
|
1295
|
+
return initial;
|
|
1296
|
+
return coll.split('').reduceRight(function (result, elem, index) {
|
|
1297
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1298
|
+
}, initial);
|
|
1299
|
+
}
|
|
1300
|
+
else if (Array.isArray(coll)) {
|
|
1301
|
+
if (coll.length === 0)
|
|
1302
|
+
return initial;
|
|
1303
|
+
return coll.reduceRight(function (result, elem, index) {
|
|
1304
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1305
|
+
}, initial);
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
if (Object.keys(coll).length === 0)
|
|
1309
|
+
return initial;
|
|
1310
|
+
return Object.entries(coll).reduceRight(function (result, _a) {
|
|
1311
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1312
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1313
|
+
}, initial);
|
|
1314
|
+
}
|
|
1315
|
+
},
|
|
1316
|
+
paramCount: 3,
|
|
1317
|
+
},
|
|
1198
1318
|
'reductions': {
|
|
1199
1319
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1200
1320
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1241,6 +1361,52 @@ var collectionNormalExpression = {
|
|
|
1241
1361
|
},
|
|
1242
1362
|
paramCount: 3,
|
|
1243
1363
|
},
|
|
1364
|
+
'reductionsi': {
|
|
1365
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1366
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1367
|
+
var executeFunction = _b.executeFunction;
|
|
1368
|
+
assertColl(coll, sourceCodeInfo);
|
|
1369
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1370
|
+
assertAny(initial, sourceCodeInfo);
|
|
1371
|
+
assertAny(initial, sourceCodeInfo);
|
|
1372
|
+
if (typeof coll === 'string') {
|
|
1373
|
+
assertString(initial, sourceCodeInfo);
|
|
1374
|
+
if (coll.length === 0)
|
|
1375
|
+
return [initial];
|
|
1376
|
+
var resultArray_4 = [initial];
|
|
1377
|
+
coll.split('').reduce(function (result, elem, index) {
|
|
1378
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1379
|
+
resultArray_4.push(newVal);
|
|
1380
|
+
return newVal;
|
|
1381
|
+
}, initial);
|
|
1382
|
+
return resultArray_4;
|
|
1383
|
+
}
|
|
1384
|
+
else if (Array.isArray(coll)) {
|
|
1385
|
+
if (coll.length === 0)
|
|
1386
|
+
return [initial];
|
|
1387
|
+
var resultArray_5 = [initial];
|
|
1388
|
+
coll.reduce(function (result, elem, index) {
|
|
1389
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1390
|
+
resultArray_5.push(newVal);
|
|
1391
|
+
return newVal;
|
|
1392
|
+
}, initial);
|
|
1393
|
+
return resultArray_5;
|
|
1394
|
+
}
|
|
1395
|
+
else {
|
|
1396
|
+
if (Object.keys(coll).length === 0)
|
|
1397
|
+
return [initial];
|
|
1398
|
+
var resultArray_6 = [initial];
|
|
1399
|
+
Object.entries(coll).reduce(function (result, _a) {
|
|
1400
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1401
|
+
var newVal = executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1402
|
+
resultArray_6.push(newVal);
|
|
1403
|
+
return newVal;
|
|
1404
|
+
}, initial);
|
|
1405
|
+
return resultArray_6;
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
paramCount: 3,
|
|
1409
|
+
},
|
|
1244
1410
|
'get': {
|
|
1245
1411
|
evaluate: function (params, sourceCodeInfo) {
|
|
1246
1412
|
var _a = __read(params, 2), coll = _a[0], key = _a[1];
|
|
@@ -1494,7 +1660,7 @@ var collectionNormalExpression = {
|
|
|
1494
1660
|
};
|
|
1495
1661
|
|
|
1496
1662
|
var arrayNormalExpression = {
|
|
1497
|
-
range: {
|
|
1663
|
+
'range': {
|
|
1498
1664
|
evaluate: function (params, sourceCodeInfo) {
|
|
1499
1665
|
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
1500
1666
|
var from;
|
|
@@ -1532,7 +1698,7 @@ var arrayNormalExpression = {
|
|
|
1532
1698
|
},
|
|
1533
1699
|
paramCount: { min: 1, max: 3 },
|
|
1534
1700
|
},
|
|
1535
|
-
repeat: {
|
|
1701
|
+
'repeat': {
|
|
1536
1702
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1537
1703
|
var _b = __read(_a, 2), value = _b[0], count = _b[1];
|
|
1538
1704
|
assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
@@ -1543,7 +1709,7 @@ var arrayNormalExpression = {
|
|
|
1543
1709
|
},
|
|
1544
1710
|
paramCount: 2,
|
|
1545
1711
|
},
|
|
1546
|
-
flatten: {
|
|
1712
|
+
'flatten': {
|
|
1547
1713
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1548
1714
|
var _b = __read(_a, 2), seq = _b[0], depth = _b[1];
|
|
1549
1715
|
assertArray(seq, sourceCodeInfo);
|
|
@@ -1554,7 +1720,7 @@ var arrayNormalExpression = {
|
|
|
1554
1720
|
},
|
|
1555
1721
|
paramCount: { min: 1, max: 2 },
|
|
1556
1722
|
},
|
|
1557
|
-
mapcat: {
|
|
1723
|
+
'mapcat': {
|
|
1558
1724
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1559
1725
|
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1560
1726
|
var executeFunction = _b.executeFunction;
|
|
@@ -1564,6 +1730,38 @@ var arrayNormalExpression = {
|
|
|
1564
1730
|
},
|
|
1565
1731
|
paramCount: 2,
|
|
1566
1732
|
},
|
|
1733
|
+
'moving-fn': {
|
|
1734
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1735
|
+
var _c = __read(_a, 3), arr = _c[0], windowSize = _c[1], fn = _c[2];
|
|
1736
|
+
var executeFunction = _b.executeFunction;
|
|
1737
|
+
assertArray(arr, sourceCodeInfo);
|
|
1738
|
+
assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length });
|
|
1739
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1740
|
+
var result = [];
|
|
1741
|
+
for (var i = 0; i <= arr.length - windowSize; i++) {
|
|
1742
|
+
var window_1 = arr.slice(i, i + windowSize);
|
|
1743
|
+
var value = executeFunction(fn, [window_1], contextStack, sourceCodeInfo);
|
|
1744
|
+
result.push(value);
|
|
1745
|
+
}
|
|
1746
|
+
return result;
|
|
1747
|
+
},
|
|
1748
|
+
paramCount: 3,
|
|
1749
|
+
},
|
|
1750
|
+
'running-fn': {
|
|
1751
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1752
|
+
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1753
|
+
var executeFunction = _b.executeFunction;
|
|
1754
|
+
assertArray(arr, sourceCodeInfo);
|
|
1755
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1756
|
+
var result = [];
|
|
1757
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
1758
|
+
var subArr = arr.slice(0, i + 1);
|
|
1759
|
+
result.push(executeFunction(fn, [subArr], contextStack, sourceCodeInfo));
|
|
1760
|
+
}
|
|
1761
|
+
return result;
|
|
1762
|
+
},
|
|
1763
|
+
paramCount: 2,
|
|
1764
|
+
},
|
|
1567
1765
|
};
|
|
1568
1766
|
|
|
1569
1767
|
var sequenceNormalExpression = {
|
|
@@ -2295,7 +2493,7 @@ function isVector(vector) {
|
|
|
2295
2493
|
if (vectors.has(vector)) {
|
|
2296
2494
|
return true;
|
|
2297
2495
|
}
|
|
2298
|
-
if (vector.every(function (elem) { return isNumber(elem
|
|
2496
|
+
if (vector.every(function (elem) { return isNumber(elem); })) {
|
|
2299
2497
|
annotatedArrays.add(vector);
|
|
2300
2498
|
vectors.add(vector);
|
|
2301
2499
|
return true;
|
|
@@ -2404,7 +2602,7 @@ function isMatrix(matrix) {
|
|
|
2404
2602
|
if (row.length !== nbrOfCols) {
|
|
2405
2603
|
return false;
|
|
2406
2604
|
}
|
|
2407
|
-
if (row.some(function (cell) { return !isNumber(cell
|
|
2605
|
+
if (row.some(function (cell) { return !isNumber(cell); })) {
|
|
2408
2606
|
return false;
|
|
2409
2607
|
}
|
|
2410
2608
|
}
|
|
@@ -3937,14 +4135,6 @@ var predicatesNormalExpression = {
|
|
|
3937
4135
|
},
|
|
3938
4136
|
paramCount: 1,
|
|
3939
4137
|
},
|
|
3940
|
-
'nan?': {
|
|
3941
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
3942
|
-
var _b = __read(_a, 1), value = _b[0];
|
|
3943
|
-
assertNumber(value, sourceCodeInfo);
|
|
3944
|
-
return Number.isNaN(value);
|
|
3945
|
-
},
|
|
3946
|
-
paramCount: 1,
|
|
3947
|
-
},
|
|
3948
4138
|
'positive-infinity?': {
|
|
3949
4139
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3950
4140
|
var _b = __read(_a, 1), value = _b[0];
|
|
@@ -12253,10 +12443,7 @@ var functionExecutors = {
|
|
|
12253
12443
|
NativeJsFunction: function (fn, params, sourceCodeInfo) {
|
|
12254
12444
|
var _a;
|
|
12255
12445
|
try {
|
|
12256
|
-
|
|
12257
|
-
var clonedParams = JSON.parse(JSON.stringify(params));
|
|
12258
|
-
// eslint-disable-next-line ts/no-unsafe-argument
|
|
12259
|
-
return toAny((_a = fn.nativeFn).fn.apply(_a, __spreadArray([], __read(clonedParams), false)));
|
|
12446
|
+
return toAny((_a = fn.nativeFn).fn.apply(_a, __spreadArray([], __read(params), false)));
|
|
12260
12447
|
}
|
|
12261
12448
|
catch (error) {
|
|
12262
12449
|
var message = typeof error === 'string'
|
|
@@ -12506,8 +12693,13 @@ function evaluateNode(node, contextStack) {
|
|
|
12506
12693
|
return contextStack.evaluateSymbol(node);
|
|
12507
12694
|
case NodeTypes.ReservedSymbol:
|
|
12508
12695
|
return evaluateReservedSymbol(node);
|
|
12509
|
-
case NodeTypes.NormalExpression:
|
|
12510
|
-
|
|
12696
|
+
case NodeTypes.NormalExpression: {
|
|
12697
|
+
var result = evaluateNormalExpression(node, contextStack);
|
|
12698
|
+
if (typeof result === 'number' && Number.isNaN(result)) {
|
|
12699
|
+
throw new LitsError('Number is NaN', node[2]);
|
|
12700
|
+
}
|
|
12701
|
+
return annotate(result);
|
|
12702
|
+
}
|
|
12511
12703
|
case NodeTypes.SpecialExpression:
|
|
12512
12704
|
return annotate(evaluateSpecialExpression(node, contextStack));
|
|
12513
12705
|
/* v8 ignore next 2 */
|
|
@@ -15070,10 +15262,15 @@ function getVectorReductionNames(name) {
|
|
|
15070
15262
|
var api = {
|
|
15071
15263
|
collection: [
|
|
15072
15264
|
'filter',
|
|
15265
|
+
'filteri',
|
|
15073
15266
|
'map',
|
|
15267
|
+
'mapi',
|
|
15074
15268
|
'reduce',
|
|
15269
|
+
'reducei',
|
|
15075
15270
|
'reduce-right',
|
|
15271
|
+
'reducei-right',
|
|
15076
15272
|
'reductions',
|
|
15273
|
+
'reductionsi',
|
|
15077
15274
|
'count',
|
|
15078
15275
|
'get',
|
|
15079
15276
|
'get-in',
|
|
@@ -15094,6 +15291,8 @@ var api = {
|
|
|
15094
15291
|
'repeat',
|
|
15095
15292
|
'flatten',
|
|
15096
15293
|
'mapcat',
|
|
15294
|
+
'moving-fn',
|
|
15295
|
+
'running-fn',
|
|
15097
15296
|
],
|
|
15098
15297
|
sequence: [
|
|
15099
15298
|
'nth',
|
|
@@ -15233,7 +15432,6 @@ var api = {
|
|
|
15233
15432
|
'even?',
|
|
15234
15433
|
'odd?',
|
|
15235
15434
|
'finite?',
|
|
15236
|
-
'nan?',
|
|
15237
15435
|
'negative-infinity?',
|
|
15238
15436
|
'positive-infinity?',
|
|
15239
15437
|
'false?',
|
|
@@ -15549,7 +15747,7 @@ function getOperatorArgs(a, b) {
|
|
|
15549
15747
|
}
|
|
15550
15748
|
|
|
15551
15749
|
var arrayReference = {
|
|
15552
|
-
range: {
|
|
15750
|
+
'range': {
|
|
15553
15751
|
title: 'range',
|
|
15554
15752
|
category: 'Array',
|
|
15555
15753
|
linkName: 'range',
|
|
@@ -15574,7 +15772,7 @@ var arrayReference = {
|
|
|
15574
15772
|
"\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)",
|
|
15575
15773
|
],
|
|
15576
15774
|
},
|
|
15577
|
-
repeat: {
|
|
15775
|
+
'repeat': {
|
|
15578
15776
|
title: 'repeat',
|
|
15579
15777
|
category: 'Array',
|
|
15580
15778
|
linkName: 'repeat',
|
|
@@ -15593,7 +15791,7 @@ var arrayReference = {
|
|
|
15593
15791
|
'"Albert" repeat 5',
|
|
15594
15792
|
],
|
|
15595
15793
|
},
|
|
15596
|
-
flatten: {
|
|
15794
|
+
'flatten': {
|
|
15597
15795
|
title: 'flatten',
|
|
15598
15796
|
category: 'Array',
|
|
15599
15797
|
linkName: 'flatten',
|
|
@@ -15617,7 +15815,7 @@ var arrayReference = {
|
|
|
15617
15815
|
],
|
|
15618
15816
|
noOperatorDocumentation: true,
|
|
15619
15817
|
},
|
|
15620
|
-
mapcat: {
|
|
15818
|
+
'mapcat': {
|
|
15621
15819
|
title: 'mapcat',
|
|
15622
15820
|
category: 'Array',
|
|
15623
15821
|
linkName: 'mapcat',
|
|
@@ -15642,6 +15840,60 @@ var arrayReference = {
|
|
|
15642
15840
|
"\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
|
|
15643
15841
|
],
|
|
15644
15842
|
},
|
|
15843
|
+
'moving-fn': {
|
|
15844
|
+
title: 'moving-fn',
|
|
15845
|
+
category: 'Array',
|
|
15846
|
+
linkName: 'moving-fn',
|
|
15847
|
+
returns: {
|
|
15848
|
+
type: 'array',
|
|
15849
|
+
},
|
|
15850
|
+
args: {
|
|
15851
|
+
arr: {
|
|
15852
|
+
type: 'array',
|
|
15853
|
+
},
|
|
15854
|
+
windowSize: {
|
|
15855
|
+
type: 'number',
|
|
15856
|
+
description: 'The size of the moving window.',
|
|
15857
|
+
},
|
|
15858
|
+
fn: {
|
|
15859
|
+
type: 'function',
|
|
15860
|
+
},
|
|
15861
|
+
},
|
|
15862
|
+
variants: [{
|
|
15863
|
+
argumentNames: ['arr', 'windowSize', 'fn'],
|
|
15864
|
+
}],
|
|
15865
|
+
description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',
|
|
15866
|
+
examples: [
|
|
15867
|
+
'moving-fn([1, 2, 3], 2, vec:sum)',
|
|
15868
|
+
'moving-fn([1, 2, 3], 1, vec:sum)',
|
|
15869
|
+
'moving-fn([1, 2, 3], 3, vec:sum)',
|
|
15870
|
+
],
|
|
15871
|
+
},
|
|
15872
|
+
'running-fn': {
|
|
15873
|
+
title: 'running-fn',
|
|
15874
|
+
category: 'Array',
|
|
15875
|
+
linkName: 'running-fn',
|
|
15876
|
+
returns: {
|
|
15877
|
+
type: 'array',
|
|
15878
|
+
},
|
|
15879
|
+
args: {
|
|
15880
|
+
a: {
|
|
15881
|
+
type: 'array',
|
|
15882
|
+
},
|
|
15883
|
+
b: {
|
|
15884
|
+
type: 'function',
|
|
15885
|
+
},
|
|
15886
|
+
},
|
|
15887
|
+
variants: [{
|
|
15888
|
+
argumentNames: ['a', 'b'],
|
|
15889
|
+
}],
|
|
15890
|
+
description: 'Returns the result of applying $b to each element of $a.',
|
|
15891
|
+
examples: [
|
|
15892
|
+
'running-fn([1, 2, 3], vec:sum)',
|
|
15893
|
+
'running-fn([1, 2, 3], vec:max)',
|
|
15894
|
+
'running-fn([1, 2, 3], vec:min)',
|
|
15895
|
+
],
|
|
15896
|
+
},
|
|
15645
15897
|
};
|
|
15646
15898
|
|
|
15647
15899
|
var assertReference = {
|
|
@@ -16302,6 +16554,32 @@ var collectionReference = {
|
|
|
16302
16554
|
"\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
|
|
16303
16555
|
],
|
|
16304
16556
|
},
|
|
16557
|
+
'filteri': {
|
|
16558
|
+
title: 'filteri',
|
|
16559
|
+
category: 'Collection',
|
|
16560
|
+
linkName: 'filteri',
|
|
16561
|
+
returns: {
|
|
16562
|
+
type: 'collection',
|
|
16563
|
+
},
|
|
16564
|
+
args: {
|
|
16565
|
+
a: {
|
|
16566
|
+
type: 'collection',
|
|
16567
|
+
},
|
|
16568
|
+
b: {
|
|
16569
|
+
type: 'function',
|
|
16570
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16571
|
+
},
|
|
16572
|
+
},
|
|
16573
|
+
variants: [
|
|
16574
|
+
{ argumentNames: ['a', 'b'] },
|
|
16575
|
+
],
|
|
16576
|
+
description: 'Creates a new collection with all elements that pass the test implemented by $b. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.',
|
|
16577
|
+
examples: [
|
|
16578
|
+
'filteri([1, 2, 3], (x, i) -> i % 2 = 0)',
|
|
16579
|
+
'filteri([1, 2, 3], (x, i) -> x % 2 = 0)',
|
|
16580
|
+
'filteri([1, 2, 3], (x, i) -> x + i > 3)',
|
|
16581
|
+
],
|
|
16582
|
+
},
|
|
16305
16583
|
'map': {
|
|
16306
16584
|
title: 'map',
|
|
16307
16585
|
category: 'Collection',
|
|
@@ -16330,6 +16608,34 @@ var collectionReference = {
|
|
|
16330
16608
|
'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
|
|
16331
16609
|
],
|
|
16332
16610
|
},
|
|
16611
|
+
'mapi': {
|
|
16612
|
+
title: 'mapi',
|
|
16613
|
+
category: 'Collection',
|
|
16614
|
+
linkName: 'mapi',
|
|
16615
|
+
returns: {
|
|
16616
|
+
type: 'collection',
|
|
16617
|
+
},
|
|
16618
|
+
args: {
|
|
16619
|
+
a: {
|
|
16620
|
+
type: 'collection',
|
|
16621
|
+
},
|
|
16622
|
+
b: {
|
|
16623
|
+
type: 'function',
|
|
16624
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16625
|
+
},
|
|
16626
|
+
},
|
|
16627
|
+
variants: [
|
|
16628
|
+
{ argumentNames: ['a', 'b'] },
|
|
16629
|
+
],
|
|
16630
|
+
description: 'Creates a new collection populated with the results of calling $b on every element in $a. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.',
|
|
16631
|
+
examples: [
|
|
16632
|
+
'mapi([1, 2, 3], (x, i) -> x + i)',
|
|
16633
|
+
'mapi([1, 2, 3], (x, i) -> x * i)',
|
|
16634
|
+
'mapi([1, 2, 3], (x, i) -> x - i)',
|
|
16635
|
+
'mapi([1, 2, 3], (x, i) -> x / i)',
|
|
16636
|
+
'mapi([1, 2, 3], (x, i) -> x % inc(i))',
|
|
16637
|
+
],
|
|
16638
|
+
},
|
|
16333
16639
|
'reduce': {
|
|
16334
16640
|
title: 'reduce',
|
|
16335
16641
|
category: 'Collection',
|
|
@@ -16386,12 +16692,73 @@ var collectionReference = {
|
|
|
16386
16692
|
'reduce-right({ a := 1, b := 2 }, +, 0)',
|
|
16387
16693
|
],
|
|
16388
16694
|
},
|
|
16695
|
+
'reducei-right': {
|
|
16696
|
+
title: 'reducei-right',
|
|
16697
|
+
category: 'Collection',
|
|
16698
|
+
linkName: 'reducei-right',
|
|
16699
|
+
returns: {
|
|
16700
|
+
type: 'any',
|
|
16701
|
+
},
|
|
16702
|
+
args: {
|
|
16703
|
+
coll: {
|
|
16704
|
+
type: 'collection',
|
|
16705
|
+
},
|
|
16706
|
+
fun: {
|
|
16707
|
+
type: 'function',
|
|
16708
|
+
description: 'The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.',
|
|
16709
|
+
},
|
|
16710
|
+
initial: {
|
|
16711
|
+
type: 'any',
|
|
16712
|
+
description: 'The initial value to use as the accumulator.',
|
|
16713
|
+
},
|
|
16714
|
+
},
|
|
16715
|
+
variants: [
|
|
16716
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16717
|
+
],
|
|
16718
|
+
description: 'Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.',
|
|
16719
|
+
examples: [
|
|
16720
|
+
'reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16721
|
+
'reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16722
|
+
'reducei-right({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16723
|
+
],
|
|
16724
|
+
},
|
|
16725
|
+
'reducei': {
|
|
16726
|
+
title: 'reducei',
|
|
16727
|
+
category: 'Collection',
|
|
16728
|
+
linkName: 'reducei',
|
|
16729
|
+
returns: {
|
|
16730
|
+
type: 'any',
|
|
16731
|
+
},
|
|
16732
|
+
args: {
|
|
16733
|
+
coll: {
|
|
16734
|
+
type: 'collection',
|
|
16735
|
+
},
|
|
16736
|
+
fun: {
|
|
16737
|
+
type: 'function',
|
|
16738
|
+
description: 'The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.',
|
|
16739
|
+
},
|
|
16740
|
+
initial: {
|
|
16741
|
+
type: 'any',
|
|
16742
|
+
description: 'The initial value to use as the accumulator.',
|
|
16743
|
+
},
|
|
16744
|
+
},
|
|
16745
|
+
variants: [
|
|
16746
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16747
|
+
],
|
|
16748
|
+
description: 'Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.',
|
|
16749
|
+
examples: [
|
|
16750
|
+
'reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16751
|
+
'reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16752
|
+
'reducei({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16753
|
+
],
|
|
16754
|
+
},
|
|
16389
16755
|
'reductions': {
|
|
16390
16756
|
title: 'reductions',
|
|
16391
16757
|
category: 'Collection',
|
|
16392
16758
|
linkName: 'reductions',
|
|
16393
16759
|
returns: {
|
|
16394
16760
|
type: 'any',
|
|
16761
|
+
array: true,
|
|
16395
16762
|
},
|
|
16396
16763
|
args: {
|
|
16397
16764
|
fun: {
|
|
@@ -16416,6 +16783,37 @@ var collectionReference = {
|
|
|
16416
16783
|
"\nreductions(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + if even?(value) then value else 0 end,\n 0\n)",
|
|
16417
16784
|
],
|
|
16418
16785
|
},
|
|
16786
|
+
'reductionsi': {
|
|
16787
|
+
title: 'reductionsi',
|
|
16788
|
+
category: 'Collection',
|
|
16789
|
+
linkName: 'reductionsi',
|
|
16790
|
+
returns: {
|
|
16791
|
+
type: 'any',
|
|
16792
|
+
array: true,
|
|
16793
|
+
},
|
|
16794
|
+
args: {
|
|
16795
|
+
coll: {
|
|
16796
|
+
type: 'collection',
|
|
16797
|
+
},
|
|
16798
|
+
fun: {
|
|
16799
|
+
type: 'function',
|
|
16800
|
+
description: 'The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.',
|
|
16801
|
+
},
|
|
16802
|
+
initial: {
|
|
16803
|
+
type: 'any',
|
|
16804
|
+
description: 'The initial value to use as the accumulator.',
|
|
16805
|
+
},
|
|
16806
|
+
},
|
|
16807
|
+
variants: [
|
|
16808
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16809
|
+
],
|
|
16810
|
+
description: 'Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.',
|
|
16811
|
+
examples: [
|
|
16812
|
+
'reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16813
|
+
'reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16814
|
+
'reductionsi({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16815
|
+
],
|
|
16816
|
+
},
|
|
16419
16817
|
'count': {
|
|
16420
16818
|
title: 'count',
|
|
16421
16819
|
category: 'Collection',
|
|
@@ -24880,30 +25278,6 @@ var predicateReference = {
|
|
|
24880
25278
|
'finite?(1.0)',
|
|
24881
25279
|
'finite?(1 / 0)',
|
|
24882
25280
|
'finite?(-1 / 0)',
|
|
24883
|
-
'finite?(sqrt(-1))',
|
|
24884
|
-
],
|
|
24885
|
-
},
|
|
24886
|
-
'nan?': {
|
|
24887
|
-
title: 'nan?',
|
|
24888
|
-
category: 'Predicate',
|
|
24889
|
-
linkName: 'nan-question',
|
|
24890
|
-
returns: {
|
|
24891
|
-
type: 'boolean',
|
|
24892
|
-
},
|
|
24893
|
-
args: {
|
|
24894
|
-
x: {
|
|
24895
|
-
type: 'number',
|
|
24896
|
-
},
|
|
24897
|
-
},
|
|
24898
|
-
variants: [
|
|
24899
|
-
{ argumentNames: ['x'] },
|
|
24900
|
-
],
|
|
24901
|
-
description: 'Returns `true` if $x is NaN (! a number), otherwise `false`.',
|
|
24902
|
-
examples: [
|
|
24903
|
-
'nan?(1.0)',
|
|
24904
|
-
'nan?(1 / 0)',
|
|
24905
|
-
'nan?(-1 / 0)',
|
|
24906
|
-
'nan?(sqrt(-1))',
|
|
24907
25281
|
],
|
|
24908
25282
|
},
|
|
24909
25283
|
'negative-infinity?': {
|
|
@@ -24926,7 +25300,6 @@ var predicateReference = {
|
|
|
24926
25300
|
'negative-infinity?(1.0)',
|
|
24927
25301
|
'negative-infinity?(1 / 0)',
|
|
24928
25302
|
'negative-infinity?(-1 / 0)',
|
|
24929
|
-
'negative-infinity?(sqrt(-1))',
|
|
24930
25303
|
],
|
|
24931
25304
|
},
|
|
24932
25305
|
'positive-infinity?': {
|
|
@@ -24949,7 +25322,6 @@ var predicateReference = {
|
|
|
24949
25322
|
'positive-infinity?(1.0)',
|
|
24950
25323
|
'positive-infinity?(1 / 0)',
|
|
24951
25324
|
'positive-infinity?(-1 / 0)',
|
|
24952
|
-
'positive-infinity?(sqrt(-1))',
|
|
24953
25325
|
],
|
|
24954
25326
|
},
|
|
24955
25327
|
'false?': {
|
|
@@ -30781,7 +31153,6 @@ var numberTheoryReference = __assign(__assign(__assign(__assign(__assign(__assig
|
|
|
30781
31153
|
'12 nth:lcm 8',
|
|
30782
31154
|
'nth:lcm(100, 25)',
|
|
30783
31155
|
'nth:lcm(37, 1)',
|
|
30784
|
-
'nth:lcm(0, 0)',
|
|
30785
31156
|
'nth:lcm(0, 5)',
|
|
30786
31157
|
'nth:lcm(5, 0)',
|
|
30787
31158
|
],
|
|
@@ -33013,6 +33384,12 @@ class ExpressionParser {
|
|
|
33013
33384
|
* @returns A string containing the symbolic representation
|
|
33014
33385
|
*/
|
|
33015
33386
|
function prettyPi(num, config = {}) {
|
|
33387
|
+
if (isNaN(num)) {
|
|
33388
|
+
return "NaN";
|
|
33389
|
+
}
|
|
33390
|
+
if (!isFinite(num)) {
|
|
33391
|
+
return num > 0 ? "∞" : "-∞";
|
|
33392
|
+
}
|
|
33016
33393
|
setConfig(config);
|
|
33017
33394
|
const parser = new ExpressionParser();
|
|
33018
33395
|
const exprTree = parser.parseNumber(num);
|
|
@@ -33036,10 +33413,6 @@ function stringifyValue(value, html) {
|
|
|
33036
33413
|
return value.toString();
|
|
33037
33414
|
if (typeof value === 'object' && value instanceof RegExp)
|
|
33038
33415
|
return "".concat(value);
|
|
33039
|
-
if (value === Number.POSITIVE_INFINITY)
|
|
33040
|
-
return "".concat(Number.POSITIVE_INFINITY);
|
|
33041
|
-
if (value === Number.NEGATIVE_INFINITY)
|
|
33042
|
-
return "".concat(Number.NEGATIVE_INFINITY);
|
|
33043
33416
|
if (typeof value === 'number') {
|
|
33044
33417
|
return prettyPi(value);
|
|
33045
33418
|
}
|
|
@@ -33063,7 +33436,37 @@ function stringifyValue(value, html) {
|
|
|
33063
33436
|
}).join(', '), "]");
|
|
33064
33437
|
}
|
|
33065
33438
|
}
|
|
33066
|
-
return JSON.stringify(value, null, 2);
|
|
33439
|
+
return JSON.stringify(replaceInfinities(value), null, 2);
|
|
33440
|
+
}
|
|
33441
|
+
function replaceInfinities(value) {
|
|
33442
|
+
var e_1, _a;
|
|
33443
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
33444
|
+
return '∞';
|
|
33445
|
+
}
|
|
33446
|
+
if (value === Number.NEGATIVE_INFINITY) {
|
|
33447
|
+
return '-∞';
|
|
33448
|
+
}
|
|
33449
|
+
if (Array.isArray(value)) {
|
|
33450
|
+
return value.map(replaceInfinities);
|
|
33451
|
+
}
|
|
33452
|
+
if (typeof value === 'object' && value !== null) {
|
|
33453
|
+
var result = {};
|
|
33454
|
+
try {
|
|
33455
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
33456
|
+
var _d = __read(_c.value, 2), key = _d[0], val = _d[1];
|
|
33457
|
+
result[key] = replaceInfinities(val);
|
|
33458
|
+
}
|
|
33459
|
+
}
|
|
33460
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33461
|
+
finally {
|
|
33462
|
+
try {
|
|
33463
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
33464
|
+
}
|
|
33465
|
+
finally { if (e_1) throw e_1.error; }
|
|
33466
|
+
}
|
|
33467
|
+
return result;
|
|
33468
|
+
}
|
|
33469
|
+
return value;
|
|
33067
33470
|
}
|
|
33068
33471
|
function prettyIfNumber(value) {
|
|
33069
33472
|
if (typeof value === 'number') {
|