@mojir/lits 2.1.12 → 2.1.13
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 +460 -54
- package/dist/cli/reference/api.d.ts +4 -4
- package/dist/cli/reference/index.d.ts +7 -1
- package/dist/index.esm.js +422 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +422 -48
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +422 -48
- 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 +211 -16
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +211 -16
- 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.13";
|
|
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];
|
|
@@ -12506,8 +12696,13 @@ function evaluateNode(node, contextStack) {
|
|
|
12506
12696
|
return contextStack.evaluateSymbol(node);
|
|
12507
12697
|
case NodeTypes.ReservedSymbol:
|
|
12508
12698
|
return evaluateReservedSymbol(node);
|
|
12509
|
-
case NodeTypes.NormalExpression:
|
|
12510
|
-
|
|
12699
|
+
case NodeTypes.NormalExpression: {
|
|
12700
|
+
var result = evaluateNormalExpression(node, contextStack);
|
|
12701
|
+
if (typeof result === 'number' && Number.isNaN(result)) {
|
|
12702
|
+
throw new LitsError('Number is NaN', node[2]);
|
|
12703
|
+
}
|
|
12704
|
+
return annotate(result);
|
|
12705
|
+
}
|
|
12511
12706
|
case NodeTypes.SpecialExpression:
|
|
12512
12707
|
return annotate(evaluateSpecialExpression(node, contextStack));
|
|
12513
12708
|
/* v8 ignore next 2 */
|
|
@@ -15070,10 +15265,15 @@ function getVectorReductionNames(name) {
|
|
|
15070
15265
|
var api = {
|
|
15071
15266
|
collection: [
|
|
15072
15267
|
'filter',
|
|
15268
|
+
'filteri',
|
|
15073
15269
|
'map',
|
|
15270
|
+
'mapi',
|
|
15074
15271
|
'reduce',
|
|
15272
|
+
'reducei',
|
|
15075
15273
|
'reduce-right',
|
|
15274
|
+
'reducei-right',
|
|
15076
15275
|
'reductions',
|
|
15276
|
+
'reductionsi',
|
|
15077
15277
|
'count',
|
|
15078
15278
|
'get',
|
|
15079
15279
|
'get-in',
|
|
@@ -15094,6 +15294,8 @@ var api = {
|
|
|
15094
15294
|
'repeat',
|
|
15095
15295
|
'flatten',
|
|
15096
15296
|
'mapcat',
|
|
15297
|
+
'moving-fn',
|
|
15298
|
+
'running-fn',
|
|
15097
15299
|
],
|
|
15098
15300
|
sequence: [
|
|
15099
15301
|
'nth',
|
|
@@ -15233,7 +15435,6 @@ var api = {
|
|
|
15233
15435
|
'even?',
|
|
15234
15436
|
'odd?',
|
|
15235
15437
|
'finite?',
|
|
15236
|
-
'nan?',
|
|
15237
15438
|
'negative-infinity?',
|
|
15238
15439
|
'positive-infinity?',
|
|
15239
15440
|
'false?',
|
|
@@ -15549,7 +15750,7 @@ function getOperatorArgs(a, b) {
|
|
|
15549
15750
|
}
|
|
15550
15751
|
|
|
15551
15752
|
var arrayReference = {
|
|
15552
|
-
range: {
|
|
15753
|
+
'range': {
|
|
15553
15754
|
title: 'range',
|
|
15554
15755
|
category: 'Array',
|
|
15555
15756
|
linkName: 'range',
|
|
@@ -15574,7 +15775,7 @@ var arrayReference = {
|
|
|
15574
15775
|
"\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)",
|
|
15575
15776
|
],
|
|
15576
15777
|
},
|
|
15577
|
-
repeat: {
|
|
15778
|
+
'repeat': {
|
|
15578
15779
|
title: 'repeat',
|
|
15579
15780
|
category: 'Array',
|
|
15580
15781
|
linkName: 'repeat',
|
|
@@ -15593,7 +15794,7 @@ var arrayReference = {
|
|
|
15593
15794
|
'"Albert" repeat 5',
|
|
15594
15795
|
],
|
|
15595
15796
|
},
|
|
15596
|
-
flatten: {
|
|
15797
|
+
'flatten': {
|
|
15597
15798
|
title: 'flatten',
|
|
15598
15799
|
category: 'Array',
|
|
15599
15800
|
linkName: 'flatten',
|
|
@@ -15617,7 +15818,7 @@ var arrayReference = {
|
|
|
15617
15818
|
],
|
|
15618
15819
|
noOperatorDocumentation: true,
|
|
15619
15820
|
},
|
|
15620
|
-
mapcat: {
|
|
15821
|
+
'mapcat': {
|
|
15621
15822
|
title: 'mapcat',
|
|
15622
15823
|
category: 'Array',
|
|
15623
15824
|
linkName: 'mapcat',
|
|
@@ -15642,6 +15843,60 @@ var arrayReference = {
|
|
|
15642
15843
|
"\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
|
|
15643
15844
|
],
|
|
15644
15845
|
},
|
|
15846
|
+
'moving-fn': {
|
|
15847
|
+
title: 'moving-fn',
|
|
15848
|
+
category: 'Array',
|
|
15849
|
+
linkName: 'moving-fn',
|
|
15850
|
+
returns: {
|
|
15851
|
+
type: 'array',
|
|
15852
|
+
},
|
|
15853
|
+
args: {
|
|
15854
|
+
arr: {
|
|
15855
|
+
type: 'array',
|
|
15856
|
+
},
|
|
15857
|
+
windowSize: {
|
|
15858
|
+
type: 'number',
|
|
15859
|
+
description: 'The size of the moving window.',
|
|
15860
|
+
},
|
|
15861
|
+
fn: {
|
|
15862
|
+
type: 'function',
|
|
15863
|
+
},
|
|
15864
|
+
},
|
|
15865
|
+
variants: [{
|
|
15866
|
+
argumentNames: ['arr', 'windowSize', 'fn'],
|
|
15867
|
+
}],
|
|
15868
|
+
description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',
|
|
15869
|
+
examples: [
|
|
15870
|
+
'moving-fn([1, 2, 3], 2, vec:sum)',
|
|
15871
|
+
'moving-fn([1, 2, 3], 1, vec:sum)',
|
|
15872
|
+
'moving-fn([1, 2, 3], 3, vec:sum)',
|
|
15873
|
+
],
|
|
15874
|
+
},
|
|
15875
|
+
'running-fn': {
|
|
15876
|
+
title: 'running-fn',
|
|
15877
|
+
category: 'Array',
|
|
15878
|
+
linkName: 'running-fn',
|
|
15879
|
+
returns: {
|
|
15880
|
+
type: 'array',
|
|
15881
|
+
},
|
|
15882
|
+
args: {
|
|
15883
|
+
a: {
|
|
15884
|
+
type: 'array',
|
|
15885
|
+
},
|
|
15886
|
+
b: {
|
|
15887
|
+
type: 'function',
|
|
15888
|
+
},
|
|
15889
|
+
},
|
|
15890
|
+
variants: [{
|
|
15891
|
+
argumentNames: ['a', 'b'],
|
|
15892
|
+
}],
|
|
15893
|
+
description: 'Returns the result of applying $b to each element of $a.',
|
|
15894
|
+
examples: [
|
|
15895
|
+
'running-fn([1, 2, 3], vec:sum)',
|
|
15896
|
+
'running-fn([1, 2, 3], vec:max)',
|
|
15897
|
+
'running-fn([1, 2, 3], vec:min)',
|
|
15898
|
+
],
|
|
15899
|
+
},
|
|
15645
15900
|
};
|
|
15646
15901
|
|
|
15647
15902
|
var assertReference = {
|
|
@@ -16302,6 +16557,32 @@ var collectionReference = {
|
|
|
16302
16557
|
"\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
|
|
16303
16558
|
],
|
|
16304
16559
|
},
|
|
16560
|
+
'filteri': {
|
|
16561
|
+
title: 'filteri',
|
|
16562
|
+
category: 'Collection',
|
|
16563
|
+
linkName: 'filteri',
|
|
16564
|
+
returns: {
|
|
16565
|
+
type: 'collection',
|
|
16566
|
+
},
|
|
16567
|
+
args: {
|
|
16568
|
+
a: {
|
|
16569
|
+
type: 'collection',
|
|
16570
|
+
},
|
|
16571
|
+
b: {
|
|
16572
|
+
type: 'function',
|
|
16573
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16574
|
+
},
|
|
16575
|
+
},
|
|
16576
|
+
variants: [
|
|
16577
|
+
{ argumentNames: ['a', 'b'] },
|
|
16578
|
+
],
|
|
16579
|
+
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.',
|
|
16580
|
+
examples: [
|
|
16581
|
+
'filteri([1, 2, 3], (x, i) -> i % 2 = 0)',
|
|
16582
|
+
'filteri([1, 2, 3], (x, i) -> x % 2 = 0)',
|
|
16583
|
+
'filteri([1, 2, 3], (x, i) -> x + i > 3)',
|
|
16584
|
+
],
|
|
16585
|
+
},
|
|
16305
16586
|
'map': {
|
|
16306
16587
|
title: 'map',
|
|
16307
16588
|
category: 'Collection',
|
|
@@ -16330,6 +16611,34 @@ var collectionReference = {
|
|
|
16330
16611
|
'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
|
|
16331
16612
|
],
|
|
16332
16613
|
},
|
|
16614
|
+
'mapi': {
|
|
16615
|
+
title: 'mapi',
|
|
16616
|
+
category: 'Collection',
|
|
16617
|
+
linkName: 'mapi',
|
|
16618
|
+
returns: {
|
|
16619
|
+
type: 'collection',
|
|
16620
|
+
},
|
|
16621
|
+
args: {
|
|
16622
|
+
a: {
|
|
16623
|
+
type: 'collection',
|
|
16624
|
+
},
|
|
16625
|
+
b: {
|
|
16626
|
+
type: 'function',
|
|
16627
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16628
|
+
},
|
|
16629
|
+
},
|
|
16630
|
+
variants: [
|
|
16631
|
+
{ argumentNames: ['a', 'b'] },
|
|
16632
|
+
],
|
|
16633
|
+
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.',
|
|
16634
|
+
examples: [
|
|
16635
|
+
'mapi([1, 2, 3], (x, i) -> x + i)',
|
|
16636
|
+
'mapi([1, 2, 3], (x, i) -> x * i)',
|
|
16637
|
+
'mapi([1, 2, 3], (x, i) -> x - i)',
|
|
16638
|
+
'mapi([1, 2, 3], (x, i) -> x / i)',
|
|
16639
|
+
'mapi([1, 2, 3], (x, i) -> x % inc(i))',
|
|
16640
|
+
],
|
|
16641
|
+
},
|
|
16333
16642
|
'reduce': {
|
|
16334
16643
|
title: 'reduce',
|
|
16335
16644
|
category: 'Collection',
|
|
@@ -16386,12 +16695,73 @@ var collectionReference = {
|
|
|
16386
16695
|
'reduce-right({ a := 1, b := 2 }, +, 0)',
|
|
16387
16696
|
],
|
|
16388
16697
|
},
|
|
16698
|
+
'reducei-right': {
|
|
16699
|
+
title: 'reducei-right',
|
|
16700
|
+
category: 'Collection',
|
|
16701
|
+
linkName: 'reducei-right',
|
|
16702
|
+
returns: {
|
|
16703
|
+
type: 'any',
|
|
16704
|
+
},
|
|
16705
|
+
args: {
|
|
16706
|
+
coll: {
|
|
16707
|
+
type: 'collection',
|
|
16708
|
+
},
|
|
16709
|
+
fun: {
|
|
16710
|
+
type: 'function',
|
|
16711
|
+
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.',
|
|
16712
|
+
},
|
|
16713
|
+
initial: {
|
|
16714
|
+
type: 'any',
|
|
16715
|
+
description: 'The initial value to use as the accumulator.',
|
|
16716
|
+
},
|
|
16717
|
+
},
|
|
16718
|
+
variants: [
|
|
16719
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16720
|
+
],
|
|
16721
|
+
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.',
|
|
16722
|
+
examples: [
|
|
16723
|
+
'reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16724
|
+
'reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16725
|
+
'reducei-right({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16726
|
+
],
|
|
16727
|
+
},
|
|
16728
|
+
'reducei': {
|
|
16729
|
+
title: 'reducei',
|
|
16730
|
+
category: 'Collection',
|
|
16731
|
+
linkName: 'reducei',
|
|
16732
|
+
returns: {
|
|
16733
|
+
type: 'any',
|
|
16734
|
+
},
|
|
16735
|
+
args: {
|
|
16736
|
+
coll: {
|
|
16737
|
+
type: 'collection',
|
|
16738
|
+
},
|
|
16739
|
+
fun: {
|
|
16740
|
+
type: 'function',
|
|
16741
|
+
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.',
|
|
16742
|
+
},
|
|
16743
|
+
initial: {
|
|
16744
|
+
type: 'any',
|
|
16745
|
+
description: 'The initial value to use as the accumulator.',
|
|
16746
|
+
},
|
|
16747
|
+
},
|
|
16748
|
+
variants: [
|
|
16749
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16750
|
+
],
|
|
16751
|
+
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.',
|
|
16752
|
+
examples: [
|
|
16753
|
+
'reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16754
|
+
'reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16755
|
+
'reducei({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16756
|
+
],
|
|
16757
|
+
},
|
|
16389
16758
|
'reductions': {
|
|
16390
16759
|
title: 'reductions',
|
|
16391
16760
|
category: 'Collection',
|
|
16392
16761
|
linkName: 'reductions',
|
|
16393
16762
|
returns: {
|
|
16394
16763
|
type: 'any',
|
|
16764
|
+
array: true,
|
|
16395
16765
|
},
|
|
16396
16766
|
args: {
|
|
16397
16767
|
fun: {
|
|
@@ -16416,6 +16786,37 @@ var collectionReference = {
|
|
|
16416
16786
|
"\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
16787
|
],
|
|
16418
16788
|
},
|
|
16789
|
+
'reductionsi': {
|
|
16790
|
+
title: 'reductionsi',
|
|
16791
|
+
category: 'Collection',
|
|
16792
|
+
linkName: 'reductionsi',
|
|
16793
|
+
returns: {
|
|
16794
|
+
type: 'any',
|
|
16795
|
+
array: true,
|
|
16796
|
+
},
|
|
16797
|
+
args: {
|
|
16798
|
+
coll: {
|
|
16799
|
+
type: 'collection',
|
|
16800
|
+
},
|
|
16801
|
+
fun: {
|
|
16802
|
+
type: 'function',
|
|
16803
|
+
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.',
|
|
16804
|
+
},
|
|
16805
|
+
initial: {
|
|
16806
|
+
type: 'any',
|
|
16807
|
+
description: 'The initial value to use as the accumulator.',
|
|
16808
|
+
},
|
|
16809
|
+
},
|
|
16810
|
+
variants: [
|
|
16811
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16812
|
+
],
|
|
16813
|
+
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.',
|
|
16814
|
+
examples: [
|
|
16815
|
+
'reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16816
|
+
'reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16817
|
+
'reductionsi({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16818
|
+
],
|
|
16819
|
+
},
|
|
16419
16820
|
'count': {
|
|
16420
16821
|
title: 'count',
|
|
16421
16822
|
category: 'Collection',
|
|
@@ -24880,30 +25281,6 @@ var predicateReference = {
|
|
|
24880
25281
|
'finite?(1.0)',
|
|
24881
25282
|
'finite?(1 / 0)',
|
|
24882
25283
|
'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
25284
|
],
|
|
24908
25285
|
},
|
|
24909
25286
|
'negative-infinity?': {
|
|
@@ -24926,7 +25303,6 @@ var predicateReference = {
|
|
|
24926
25303
|
'negative-infinity?(1.0)',
|
|
24927
25304
|
'negative-infinity?(1 / 0)',
|
|
24928
25305
|
'negative-infinity?(-1 / 0)',
|
|
24929
|
-
'negative-infinity?(sqrt(-1))',
|
|
24930
25306
|
],
|
|
24931
25307
|
},
|
|
24932
25308
|
'positive-infinity?': {
|
|
@@ -24949,7 +25325,6 @@ var predicateReference = {
|
|
|
24949
25325
|
'positive-infinity?(1.0)',
|
|
24950
25326
|
'positive-infinity?(1 / 0)',
|
|
24951
25327
|
'positive-infinity?(-1 / 0)',
|
|
24952
|
-
'positive-infinity?(sqrt(-1))',
|
|
24953
25328
|
],
|
|
24954
25329
|
},
|
|
24955
25330
|
'false?': {
|
|
@@ -30781,7 +31156,6 @@ var numberTheoryReference = __assign(__assign(__assign(__assign(__assign(__assig
|
|
|
30781
31156
|
'12 nth:lcm 8',
|
|
30782
31157
|
'nth:lcm(100, 25)',
|
|
30783
31158
|
'nth:lcm(37, 1)',
|
|
30784
|
-
'nth:lcm(0, 0)',
|
|
30785
31159
|
'nth:lcm(0, 5)',
|
|
30786
31160
|
'nth:lcm(5, 0)',
|
|
30787
31161
|
],
|
|
@@ -33013,6 +33387,12 @@ class ExpressionParser {
|
|
|
33013
33387
|
* @returns A string containing the symbolic representation
|
|
33014
33388
|
*/
|
|
33015
33389
|
function prettyPi(num, config = {}) {
|
|
33390
|
+
if (isNaN(num)) {
|
|
33391
|
+
return "NaN";
|
|
33392
|
+
}
|
|
33393
|
+
if (!isFinite(num)) {
|
|
33394
|
+
return num > 0 ? "∞" : "-∞";
|
|
33395
|
+
}
|
|
33016
33396
|
setConfig(config);
|
|
33017
33397
|
const parser = new ExpressionParser();
|
|
33018
33398
|
const exprTree = parser.parseNumber(num);
|
|
@@ -33036,10 +33416,6 @@ function stringifyValue(value, html) {
|
|
|
33036
33416
|
return value.toString();
|
|
33037
33417
|
if (typeof value === 'object' && value instanceof RegExp)
|
|
33038
33418
|
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
33419
|
if (typeof value === 'number') {
|
|
33044
33420
|
return prettyPi(value);
|
|
33045
33421
|
}
|
|
@@ -33063,7 +33439,37 @@ function stringifyValue(value, html) {
|
|
|
33063
33439
|
}).join(', '), "]");
|
|
33064
33440
|
}
|
|
33065
33441
|
}
|
|
33066
|
-
return JSON.stringify(value, null, 2);
|
|
33442
|
+
return JSON.stringify(replaceInfinities(value), null, 2);
|
|
33443
|
+
}
|
|
33444
|
+
function replaceInfinities(value) {
|
|
33445
|
+
var e_1, _a;
|
|
33446
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
33447
|
+
return '∞';
|
|
33448
|
+
}
|
|
33449
|
+
if (value === Number.NEGATIVE_INFINITY) {
|
|
33450
|
+
return '-∞';
|
|
33451
|
+
}
|
|
33452
|
+
if (Array.isArray(value)) {
|
|
33453
|
+
return value.map(replaceInfinities);
|
|
33454
|
+
}
|
|
33455
|
+
if (typeof value === 'object' && value !== null) {
|
|
33456
|
+
var result = {};
|
|
33457
|
+
try {
|
|
33458
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
33459
|
+
var _d = __read(_c.value, 2), key = _d[0], val = _d[1];
|
|
33460
|
+
result[key] = replaceInfinities(val);
|
|
33461
|
+
}
|
|
33462
|
+
}
|
|
33463
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33464
|
+
finally {
|
|
33465
|
+
try {
|
|
33466
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
33467
|
+
}
|
|
33468
|
+
finally { if (e_1) throw e_1.error; }
|
|
33469
|
+
}
|
|
33470
|
+
return result;
|
|
33471
|
+
}
|
|
33472
|
+
return value;
|
|
33067
33473
|
}
|
|
33068
33474
|
function prettyIfNumber(value) {
|
|
33069
33475
|
if (typeof value === 'number') {
|