@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/index.js
CHANGED
|
@@ -399,6 +399,8 @@ function isNumber(value, options) {
|
|
|
399
399
|
if (options === void 0) { options = {}; }
|
|
400
400
|
if (typeof value !== 'number')
|
|
401
401
|
return false;
|
|
402
|
+
if (Number.isNaN(value))
|
|
403
|
+
return false;
|
|
402
404
|
if (options.integer && !Number.isInteger(value))
|
|
403
405
|
return false;
|
|
404
406
|
if (options.finite && !Number.isFinite(value))
|
|
@@ -972,6 +974,35 @@ var collectionNormalExpression = {
|
|
|
972
974
|
},
|
|
973
975
|
paramCount: 2,
|
|
974
976
|
},
|
|
977
|
+
'filteri': {
|
|
978
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
979
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
980
|
+
var executeFunction = _b.executeFunction;
|
|
981
|
+
assertColl(coll, sourceCodeInfo);
|
|
982
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
983
|
+
if (Array.isArray(coll)) {
|
|
984
|
+
var result = coll.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
985
|
+
return result;
|
|
986
|
+
}
|
|
987
|
+
if (isString(coll)) {
|
|
988
|
+
return coll
|
|
989
|
+
.split('')
|
|
990
|
+
.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
991
|
+
.join('');
|
|
992
|
+
}
|
|
993
|
+
return Object.entries(coll)
|
|
994
|
+
.filter(function (_a) {
|
|
995
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
996
|
+
return executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
997
|
+
})
|
|
998
|
+
.reduce(function (result, _a) {
|
|
999
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1000
|
+
result[key] = value;
|
|
1001
|
+
return result;
|
|
1002
|
+
}, {});
|
|
1003
|
+
},
|
|
1004
|
+
paramCount: 2,
|
|
1005
|
+
},
|
|
975
1006
|
'map': {
|
|
976
1007
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
977
1008
|
var executeFunction = _a.executeFunction;
|
|
@@ -1014,6 +1045,30 @@ var collectionNormalExpression = {
|
|
|
1014
1045
|
},
|
|
1015
1046
|
paramCount: { min: 2 },
|
|
1016
1047
|
},
|
|
1048
|
+
'mapi': {
|
|
1049
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1050
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1051
|
+
var executeFunction = _b.executeFunction;
|
|
1052
|
+
assertColl(coll, sourceCodeInfo);
|
|
1053
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1054
|
+
if (Array.isArray(coll)) {
|
|
1055
|
+
return coll.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1056
|
+
}
|
|
1057
|
+
if (isString(coll)) {
|
|
1058
|
+
return coll
|
|
1059
|
+
.split('')
|
|
1060
|
+
.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1061
|
+
.join('');
|
|
1062
|
+
}
|
|
1063
|
+
return Object.entries(coll)
|
|
1064
|
+
.reduce(function (acc, _a) {
|
|
1065
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1066
|
+
acc[key] = executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1067
|
+
return acc;
|
|
1068
|
+
}, {});
|
|
1069
|
+
},
|
|
1070
|
+
paramCount: 2,
|
|
1071
|
+
},
|
|
1017
1072
|
'reduce': {
|
|
1018
1073
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1019
1074
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1047,6 +1102,39 @@ var collectionNormalExpression = {
|
|
|
1047
1102
|
},
|
|
1048
1103
|
paramCount: 3,
|
|
1049
1104
|
},
|
|
1105
|
+
'reducei': {
|
|
1106
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1107
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1108
|
+
var executeFunction = _b.executeFunction;
|
|
1109
|
+
assertColl(coll, sourceCodeInfo);
|
|
1110
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1111
|
+
assertAny(initial, sourceCodeInfo);
|
|
1112
|
+
if (typeof coll === 'string') {
|
|
1113
|
+
assertString(initial, sourceCodeInfo);
|
|
1114
|
+
if (coll.length === 0)
|
|
1115
|
+
return initial;
|
|
1116
|
+
return coll.split('').reduce(function (result, elem, index) {
|
|
1117
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1118
|
+
}, initial);
|
|
1119
|
+
}
|
|
1120
|
+
else if (Array.isArray(coll)) {
|
|
1121
|
+
if (coll.length === 0)
|
|
1122
|
+
return initial;
|
|
1123
|
+
return coll.reduce(function (result, elem, index) {
|
|
1124
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1125
|
+
}, initial);
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
if (Object.keys(coll).length === 0)
|
|
1129
|
+
return initial;
|
|
1130
|
+
return Object.entries(coll).reduce(function (result, _a) {
|
|
1131
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1132
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1133
|
+
}, initial);
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
paramCount: 3,
|
|
1137
|
+
},
|
|
1050
1138
|
'reduce-right': {
|
|
1051
1139
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1052
1140
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1079,6 +1167,38 @@ var collectionNormalExpression = {
|
|
|
1079
1167
|
},
|
|
1080
1168
|
paramCount: 3,
|
|
1081
1169
|
},
|
|
1170
|
+
'reducei-right': {
|
|
1171
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1172
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1173
|
+
var executeFunction = _b.executeFunction;
|
|
1174
|
+
assertColl(coll, sourceCodeInfo);
|
|
1175
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1176
|
+
assertAny(initial, sourceCodeInfo);
|
|
1177
|
+
if (typeof coll === 'string') {
|
|
1178
|
+
if (coll.length === 0)
|
|
1179
|
+
return initial;
|
|
1180
|
+
return coll.split('').reduceRight(function (result, elem, index) {
|
|
1181
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1182
|
+
}, initial);
|
|
1183
|
+
}
|
|
1184
|
+
else if (Array.isArray(coll)) {
|
|
1185
|
+
if (coll.length === 0)
|
|
1186
|
+
return initial;
|
|
1187
|
+
return coll.reduceRight(function (result, elem, index) {
|
|
1188
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1189
|
+
}, initial);
|
|
1190
|
+
}
|
|
1191
|
+
else {
|
|
1192
|
+
if (Object.keys(coll).length === 0)
|
|
1193
|
+
return initial;
|
|
1194
|
+
return Object.entries(coll).reduceRight(function (result, _a) {
|
|
1195
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1196
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1197
|
+
}, initial);
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
paramCount: 3,
|
|
1201
|
+
},
|
|
1082
1202
|
'reductions': {
|
|
1083
1203
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1084
1204
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1125,6 +1245,52 @@ var collectionNormalExpression = {
|
|
|
1125
1245
|
},
|
|
1126
1246
|
paramCount: 3,
|
|
1127
1247
|
},
|
|
1248
|
+
'reductionsi': {
|
|
1249
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1250
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1251
|
+
var executeFunction = _b.executeFunction;
|
|
1252
|
+
assertColl(coll, sourceCodeInfo);
|
|
1253
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1254
|
+
assertAny(initial, sourceCodeInfo);
|
|
1255
|
+
assertAny(initial, sourceCodeInfo);
|
|
1256
|
+
if (typeof coll === 'string') {
|
|
1257
|
+
assertString(initial, sourceCodeInfo);
|
|
1258
|
+
if (coll.length === 0)
|
|
1259
|
+
return [initial];
|
|
1260
|
+
var resultArray_4 = [initial];
|
|
1261
|
+
coll.split('').reduce(function (result, elem, index) {
|
|
1262
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1263
|
+
resultArray_4.push(newVal);
|
|
1264
|
+
return newVal;
|
|
1265
|
+
}, initial);
|
|
1266
|
+
return resultArray_4;
|
|
1267
|
+
}
|
|
1268
|
+
else if (Array.isArray(coll)) {
|
|
1269
|
+
if (coll.length === 0)
|
|
1270
|
+
return [initial];
|
|
1271
|
+
var resultArray_5 = [initial];
|
|
1272
|
+
coll.reduce(function (result, elem, index) {
|
|
1273
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1274
|
+
resultArray_5.push(newVal);
|
|
1275
|
+
return newVal;
|
|
1276
|
+
}, initial);
|
|
1277
|
+
return resultArray_5;
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
if (Object.keys(coll).length === 0)
|
|
1281
|
+
return [initial];
|
|
1282
|
+
var resultArray_6 = [initial];
|
|
1283
|
+
Object.entries(coll).reduce(function (result, _a) {
|
|
1284
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1285
|
+
var newVal = executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1286
|
+
resultArray_6.push(newVal);
|
|
1287
|
+
return newVal;
|
|
1288
|
+
}, initial);
|
|
1289
|
+
return resultArray_6;
|
|
1290
|
+
}
|
|
1291
|
+
},
|
|
1292
|
+
paramCount: 3,
|
|
1293
|
+
},
|
|
1128
1294
|
'get': {
|
|
1129
1295
|
evaluate: function (params, sourceCodeInfo) {
|
|
1130
1296
|
var _a = __read(params, 2), coll = _a[0], key = _a[1];
|
|
@@ -1378,7 +1544,7 @@ var collectionNormalExpression = {
|
|
|
1378
1544
|
};
|
|
1379
1545
|
|
|
1380
1546
|
var arrayNormalExpression = {
|
|
1381
|
-
range: {
|
|
1547
|
+
'range': {
|
|
1382
1548
|
evaluate: function (params, sourceCodeInfo) {
|
|
1383
1549
|
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
1384
1550
|
var from;
|
|
@@ -1416,7 +1582,7 @@ var arrayNormalExpression = {
|
|
|
1416
1582
|
},
|
|
1417
1583
|
paramCount: { min: 1, max: 3 },
|
|
1418
1584
|
},
|
|
1419
|
-
repeat: {
|
|
1585
|
+
'repeat': {
|
|
1420
1586
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1421
1587
|
var _b = __read(_a, 2), value = _b[0], count = _b[1];
|
|
1422
1588
|
assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
@@ -1427,7 +1593,7 @@ var arrayNormalExpression = {
|
|
|
1427
1593
|
},
|
|
1428
1594
|
paramCount: 2,
|
|
1429
1595
|
},
|
|
1430
|
-
flatten: {
|
|
1596
|
+
'flatten': {
|
|
1431
1597
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1432
1598
|
var _b = __read(_a, 2), seq = _b[0], depth = _b[1];
|
|
1433
1599
|
assertArray(seq, sourceCodeInfo);
|
|
@@ -1438,7 +1604,7 @@ var arrayNormalExpression = {
|
|
|
1438
1604
|
},
|
|
1439
1605
|
paramCount: { min: 1, max: 2 },
|
|
1440
1606
|
},
|
|
1441
|
-
mapcat: {
|
|
1607
|
+
'mapcat': {
|
|
1442
1608
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1443
1609
|
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1444
1610
|
var executeFunction = _b.executeFunction;
|
|
@@ -1448,6 +1614,38 @@ var arrayNormalExpression = {
|
|
|
1448
1614
|
},
|
|
1449
1615
|
paramCount: 2,
|
|
1450
1616
|
},
|
|
1617
|
+
'moving-fn': {
|
|
1618
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1619
|
+
var _c = __read(_a, 3), arr = _c[0], windowSize = _c[1], fn = _c[2];
|
|
1620
|
+
var executeFunction = _b.executeFunction;
|
|
1621
|
+
assertArray(arr, sourceCodeInfo);
|
|
1622
|
+
assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length });
|
|
1623
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1624
|
+
var result = [];
|
|
1625
|
+
for (var i = 0; i <= arr.length - windowSize; i++) {
|
|
1626
|
+
var window_1 = arr.slice(i, i + windowSize);
|
|
1627
|
+
var value = executeFunction(fn, [window_1], contextStack, sourceCodeInfo);
|
|
1628
|
+
result.push(value);
|
|
1629
|
+
}
|
|
1630
|
+
return result;
|
|
1631
|
+
},
|
|
1632
|
+
paramCount: 3,
|
|
1633
|
+
},
|
|
1634
|
+
'running-fn': {
|
|
1635
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1636
|
+
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1637
|
+
var executeFunction = _b.executeFunction;
|
|
1638
|
+
assertArray(arr, sourceCodeInfo);
|
|
1639
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1640
|
+
var result = [];
|
|
1641
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
1642
|
+
var subArr = arr.slice(0, i + 1);
|
|
1643
|
+
result.push(executeFunction(fn, [subArr], contextStack, sourceCodeInfo));
|
|
1644
|
+
}
|
|
1645
|
+
return result;
|
|
1646
|
+
},
|
|
1647
|
+
paramCount: 2,
|
|
1648
|
+
},
|
|
1451
1649
|
};
|
|
1452
1650
|
|
|
1453
1651
|
var sequenceNormalExpression = {
|
|
@@ -2179,7 +2377,7 @@ function isVector(vector) {
|
|
|
2179
2377
|
if (vectors.has(vector)) {
|
|
2180
2378
|
return true;
|
|
2181
2379
|
}
|
|
2182
|
-
if (vector.every(function (elem) { return isNumber(elem
|
|
2380
|
+
if (vector.every(function (elem) { return isNumber(elem); })) {
|
|
2183
2381
|
annotatedArrays.add(vector);
|
|
2184
2382
|
vectors.add(vector);
|
|
2185
2383
|
return true;
|
|
@@ -2288,7 +2486,7 @@ function isMatrix(matrix) {
|
|
|
2288
2486
|
if (row.length !== nbrOfCols) {
|
|
2289
2487
|
return false;
|
|
2290
2488
|
}
|
|
2291
|
-
if (row.some(function (cell) { return !isNumber(cell
|
|
2489
|
+
if (row.some(function (cell) { return !isNumber(cell); })) {
|
|
2292
2490
|
return false;
|
|
2293
2491
|
}
|
|
2294
2492
|
}
|
|
@@ -3821,14 +4019,6 @@ var predicatesNormalExpression = {
|
|
|
3821
4019
|
},
|
|
3822
4020
|
paramCount: 1,
|
|
3823
4021
|
},
|
|
3824
|
-
'nan?': {
|
|
3825
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
3826
|
-
var _b = __read(_a, 1), value = _b[0];
|
|
3827
|
-
assertNumber(value, sourceCodeInfo);
|
|
3828
|
-
return Number.isNaN(value);
|
|
3829
|
-
},
|
|
3830
|
-
paramCount: 1,
|
|
3831
|
-
},
|
|
3832
4022
|
'positive-infinity?': {
|
|
3833
4023
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3834
4024
|
var _b = __read(_a, 1), value = _b[0];
|
|
@@ -12292,10 +12482,7 @@ var functionExecutors = {
|
|
|
12292
12482
|
NativeJsFunction: function (fn, params, sourceCodeInfo) {
|
|
12293
12483
|
var _a;
|
|
12294
12484
|
try {
|
|
12295
|
-
|
|
12296
|
-
var clonedParams = JSON.parse(JSON.stringify(params));
|
|
12297
|
-
// eslint-disable-next-line ts/no-unsafe-argument
|
|
12298
|
-
return toAny((_a = fn.nativeFn).fn.apply(_a, __spreadArray([], __read(clonedParams), false)));
|
|
12485
|
+
return toAny((_a = fn.nativeFn).fn.apply(_a, __spreadArray([], __read(params), false)));
|
|
12299
12486
|
}
|
|
12300
12487
|
catch (error) {
|
|
12301
12488
|
var message = typeof error === 'string'
|
|
@@ -12545,8 +12732,13 @@ function evaluateNode(node, contextStack) {
|
|
|
12545
12732
|
return contextStack.evaluateSymbol(node);
|
|
12546
12733
|
case NodeTypes.ReservedSymbol:
|
|
12547
12734
|
return evaluateReservedSymbol(node);
|
|
12548
|
-
case NodeTypes.NormalExpression:
|
|
12549
|
-
|
|
12735
|
+
case NodeTypes.NormalExpression: {
|
|
12736
|
+
var result = evaluateNormalExpression(node, contextStack);
|
|
12737
|
+
if (typeof result === 'number' && Number.isNaN(result)) {
|
|
12738
|
+
throw new LitsError('Number is NaN', node[2]);
|
|
12739
|
+
}
|
|
12740
|
+
return annotate(result);
|
|
12741
|
+
}
|
|
12550
12742
|
case NodeTypes.SpecialExpression:
|
|
12551
12743
|
return annotate(evaluateSpecialExpression(node, contextStack));
|
|
12552
12744
|
/* v8 ignore next 2 */
|
|
@@ -14952,10 +15144,15 @@ function getVectorReductionNames(name) {
|
|
|
14952
15144
|
var api = {
|
|
14953
15145
|
collection: [
|
|
14954
15146
|
'filter',
|
|
15147
|
+
'filteri',
|
|
14955
15148
|
'map',
|
|
15149
|
+
'mapi',
|
|
14956
15150
|
'reduce',
|
|
15151
|
+
'reducei',
|
|
14957
15152
|
'reduce-right',
|
|
15153
|
+
'reducei-right',
|
|
14958
15154
|
'reductions',
|
|
15155
|
+
'reductionsi',
|
|
14959
15156
|
'count',
|
|
14960
15157
|
'get',
|
|
14961
15158
|
'get-in',
|
|
@@ -14976,6 +15173,8 @@ var api = {
|
|
|
14976
15173
|
'repeat',
|
|
14977
15174
|
'flatten',
|
|
14978
15175
|
'mapcat',
|
|
15176
|
+
'moving-fn',
|
|
15177
|
+
'running-fn',
|
|
14979
15178
|
],
|
|
14980
15179
|
sequence: [
|
|
14981
15180
|
'nth',
|
|
@@ -15115,7 +15314,6 @@ var api = {
|
|
|
15115
15314
|
'even?',
|
|
15116
15315
|
'odd?',
|
|
15117
15316
|
'finite?',
|
|
15118
|
-
'nan?',
|
|
15119
15317
|
'negative-infinity?',
|
|
15120
15318
|
'positive-infinity?',
|
|
15121
15319
|
'false?',
|
|
@@ -15452,7 +15650,7 @@ function getOperatorArgs(a, b) {
|
|
|
15452
15650
|
}
|
|
15453
15651
|
|
|
15454
15652
|
var arrayReference = {
|
|
15455
|
-
range: {
|
|
15653
|
+
'range': {
|
|
15456
15654
|
title: 'range',
|
|
15457
15655
|
category: 'Array',
|
|
15458
15656
|
linkName: 'range',
|
|
@@ -15477,7 +15675,7 @@ var arrayReference = {
|
|
|
15477
15675
|
"\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)",
|
|
15478
15676
|
],
|
|
15479
15677
|
},
|
|
15480
|
-
repeat: {
|
|
15678
|
+
'repeat': {
|
|
15481
15679
|
title: 'repeat',
|
|
15482
15680
|
category: 'Array',
|
|
15483
15681
|
linkName: 'repeat',
|
|
@@ -15496,7 +15694,7 @@ var arrayReference = {
|
|
|
15496
15694
|
'"Albert" repeat 5',
|
|
15497
15695
|
],
|
|
15498
15696
|
},
|
|
15499
|
-
flatten: {
|
|
15697
|
+
'flatten': {
|
|
15500
15698
|
title: 'flatten',
|
|
15501
15699
|
category: 'Array',
|
|
15502
15700
|
linkName: 'flatten',
|
|
@@ -15520,7 +15718,7 @@ var arrayReference = {
|
|
|
15520
15718
|
],
|
|
15521
15719
|
noOperatorDocumentation: true,
|
|
15522
15720
|
},
|
|
15523
|
-
mapcat: {
|
|
15721
|
+
'mapcat': {
|
|
15524
15722
|
title: 'mapcat',
|
|
15525
15723
|
category: 'Array',
|
|
15526
15724
|
linkName: 'mapcat',
|
|
@@ -15545,6 +15743,60 @@ var arrayReference = {
|
|
|
15545
15743
|
"\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
|
|
15546
15744
|
],
|
|
15547
15745
|
},
|
|
15746
|
+
'moving-fn': {
|
|
15747
|
+
title: 'moving-fn',
|
|
15748
|
+
category: 'Array',
|
|
15749
|
+
linkName: 'moving-fn',
|
|
15750
|
+
returns: {
|
|
15751
|
+
type: 'array',
|
|
15752
|
+
},
|
|
15753
|
+
args: {
|
|
15754
|
+
arr: {
|
|
15755
|
+
type: 'array',
|
|
15756
|
+
},
|
|
15757
|
+
windowSize: {
|
|
15758
|
+
type: 'number',
|
|
15759
|
+
description: 'The size of the moving window.',
|
|
15760
|
+
},
|
|
15761
|
+
fn: {
|
|
15762
|
+
type: 'function',
|
|
15763
|
+
},
|
|
15764
|
+
},
|
|
15765
|
+
variants: [{
|
|
15766
|
+
argumentNames: ['arr', 'windowSize', 'fn'],
|
|
15767
|
+
}],
|
|
15768
|
+
description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',
|
|
15769
|
+
examples: [
|
|
15770
|
+
'moving-fn([1, 2, 3], 2, vec:sum)',
|
|
15771
|
+
'moving-fn([1, 2, 3], 1, vec:sum)',
|
|
15772
|
+
'moving-fn([1, 2, 3], 3, vec:sum)',
|
|
15773
|
+
],
|
|
15774
|
+
},
|
|
15775
|
+
'running-fn': {
|
|
15776
|
+
title: 'running-fn',
|
|
15777
|
+
category: 'Array',
|
|
15778
|
+
linkName: 'running-fn',
|
|
15779
|
+
returns: {
|
|
15780
|
+
type: 'array',
|
|
15781
|
+
},
|
|
15782
|
+
args: {
|
|
15783
|
+
a: {
|
|
15784
|
+
type: 'array',
|
|
15785
|
+
},
|
|
15786
|
+
b: {
|
|
15787
|
+
type: 'function',
|
|
15788
|
+
},
|
|
15789
|
+
},
|
|
15790
|
+
variants: [{
|
|
15791
|
+
argumentNames: ['a', 'b'],
|
|
15792
|
+
}],
|
|
15793
|
+
description: 'Returns the result of applying $b to each element of $a.',
|
|
15794
|
+
examples: [
|
|
15795
|
+
'running-fn([1, 2, 3], vec:sum)',
|
|
15796
|
+
'running-fn([1, 2, 3], vec:max)',
|
|
15797
|
+
'running-fn([1, 2, 3], vec:min)',
|
|
15798
|
+
],
|
|
15799
|
+
},
|
|
15548
15800
|
};
|
|
15549
15801
|
|
|
15550
15802
|
var assertReference = {
|
|
@@ -16205,6 +16457,32 @@ var collectionReference = {
|
|
|
16205
16457
|
"\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
|
|
16206
16458
|
],
|
|
16207
16459
|
},
|
|
16460
|
+
'filteri': {
|
|
16461
|
+
title: 'filteri',
|
|
16462
|
+
category: 'Collection',
|
|
16463
|
+
linkName: 'filteri',
|
|
16464
|
+
returns: {
|
|
16465
|
+
type: 'collection',
|
|
16466
|
+
},
|
|
16467
|
+
args: {
|
|
16468
|
+
a: {
|
|
16469
|
+
type: 'collection',
|
|
16470
|
+
},
|
|
16471
|
+
b: {
|
|
16472
|
+
type: 'function',
|
|
16473
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16474
|
+
},
|
|
16475
|
+
},
|
|
16476
|
+
variants: [
|
|
16477
|
+
{ argumentNames: ['a', 'b'] },
|
|
16478
|
+
],
|
|
16479
|
+
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.',
|
|
16480
|
+
examples: [
|
|
16481
|
+
'filteri([1, 2, 3], (x, i) -> i % 2 = 0)',
|
|
16482
|
+
'filteri([1, 2, 3], (x, i) -> x % 2 = 0)',
|
|
16483
|
+
'filteri([1, 2, 3], (x, i) -> x + i > 3)',
|
|
16484
|
+
],
|
|
16485
|
+
},
|
|
16208
16486
|
'map': {
|
|
16209
16487
|
title: 'map',
|
|
16210
16488
|
category: 'Collection',
|
|
@@ -16233,6 +16511,34 @@ var collectionReference = {
|
|
|
16233
16511
|
'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
|
|
16234
16512
|
],
|
|
16235
16513
|
},
|
|
16514
|
+
'mapi': {
|
|
16515
|
+
title: 'mapi',
|
|
16516
|
+
category: 'Collection',
|
|
16517
|
+
linkName: 'mapi',
|
|
16518
|
+
returns: {
|
|
16519
|
+
type: 'collection',
|
|
16520
|
+
},
|
|
16521
|
+
args: {
|
|
16522
|
+
a: {
|
|
16523
|
+
type: 'collection',
|
|
16524
|
+
},
|
|
16525
|
+
b: {
|
|
16526
|
+
type: 'function',
|
|
16527
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16528
|
+
},
|
|
16529
|
+
},
|
|
16530
|
+
variants: [
|
|
16531
|
+
{ argumentNames: ['a', 'b'] },
|
|
16532
|
+
],
|
|
16533
|
+
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.',
|
|
16534
|
+
examples: [
|
|
16535
|
+
'mapi([1, 2, 3], (x, i) -> x + i)',
|
|
16536
|
+
'mapi([1, 2, 3], (x, i) -> x * i)',
|
|
16537
|
+
'mapi([1, 2, 3], (x, i) -> x - i)',
|
|
16538
|
+
'mapi([1, 2, 3], (x, i) -> x / i)',
|
|
16539
|
+
'mapi([1, 2, 3], (x, i) -> x % inc(i))',
|
|
16540
|
+
],
|
|
16541
|
+
},
|
|
16236
16542
|
'reduce': {
|
|
16237
16543
|
title: 'reduce',
|
|
16238
16544
|
category: 'Collection',
|
|
@@ -16289,12 +16595,73 @@ var collectionReference = {
|
|
|
16289
16595
|
'reduce-right({ a := 1, b := 2 }, +, 0)',
|
|
16290
16596
|
],
|
|
16291
16597
|
},
|
|
16598
|
+
'reducei-right': {
|
|
16599
|
+
title: 'reducei-right',
|
|
16600
|
+
category: 'Collection',
|
|
16601
|
+
linkName: 'reducei-right',
|
|
16602
|
+
returns: {
|
|
16603
|
+
type: 'any',
|
|
16604
|
+
},
|
|
16605
|
+
args: {
|
|
16606
|
+
coll: {
|
|
16607
|
+
type: 'collection',
|
|
16608
|
+
},
|
|
16609
|
+
fun: {
|
|
16610
|
+
type: 'function',
|
|
16611
|
+
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.',
|
|
16612
|
+
},
|
|
16613
|
+
initial: {
|
|
16614
|
+
type: 'any',
|
|
16615
|
+
description: 'The initial value to use as the accumulator.',
|
|
16616
|
+
},
|
|
16617
|
+
},
|
|
16618
|
+
variants: [
|
|
16619
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16620
|
+
],
|
|
16621
|
+
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.',
|
|
16622
|
+
examples: [
|
|
16623
|
+
'reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16624
|
+
'reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16625
|
+
'reducei-right({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16626
|
+
],
|
|
16627
|
+
},
|
|
16628
|
+
'reducei': {
|
|
16629
|
+
title: 'reducei',
|
|
16630
|
+
category: 'Collection',
|
|
16631
|
+
linkName: 'reducei',
|
|
16632
|
+
returns: {
|
|
16633
|
+
type: 'any',
|
|
16634
|
+
},
|
|
16635
|
+
args: {
|
|
16636
|
+
coll: {
|
|
16637
|
+
type: 'collection',
|
|
16638
|
+
},
|
|
16639
|
+
fun: {
|
|
16640
|
+
type: 'function',
|
|
16641
|
+
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.',
|
|
16642
|
+
},
|
|
16643
|
+
initial: {
|
|
16644
|
+
type: 'any',
|
|
16645
|
+
description: 'The initial value to use as the accumulator.',
|
|
16646
|
+
},
|
|
16647
|
+
},
|
|
16648
|
+
variants: [
|
|
16649
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16650
|
+
],
|
|
16651
|
+
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.',
|
|
16652
|
+
examples: [
|
|
16653
|
+
'reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16654
|
+
'reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16655
|
+
'reducei({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16656
|
+
],
|
|
16657
|
+
},
|
|
16292
16658
|
'reductions': {
|
|
16293
16659
|
title: 'reductions',
|
|
16294
16660
|
category: 'Collection',
|
|
16295
16661
|
linkName: 'reductions',
|
|
16296
16662
|
returns: {
|
|
16297
16663
|
type: 'any',
|
|
16664
|
+
array: true,
|
|
16298
16665
|
},
|
|
16299
16666
|
args: {
|
|
16300
16667
|
fun: {
|
|
@@ -16319,6 +16686,37 @@ var collectionReference = {
|
|
|
16319
16686
|
"\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)",
|
|
16320
16687
|
],
|
|
16321
16688
|
},
|
|
16689
|
+
'reductionsi': {
|
|
16690
|
+
title: 'reductionsi',
|
|
16691
|
+
category: 'Collection',
|
|
16692
|
+
linkName: 'reductionsi',
|
|
16693
|
+
returns: {
|
|
16694
|
+
type: 'any',
|
|
16695
|
+
array: true,
|
|
16696
|
+
},
|
|
16697
|
+
args: {
|
|
16698
|
+
coll: {
|
|
16699
|
+
type: 'collection',
|
|
16700
|
+
},
|
|
16701
|
+
fun: {
|
|
16702
|
+
type: 'function',
|
|
16703
|
+
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.',
|
|
16704
|
+
},
|
|
16705
|
+
initial: {
|
|
16706
|
+
type: 'any',
|
|
16707
|
+
description: 'The initial value to use as the accumulator.',
|
|
16708
|
+
},
|
|
16709
|
+
},
|
|
16710
|
+
variants: [
|
|
16711
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16712
|
+
],
|
|
16713
|
+
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.',
|
|
16714
|
+
examples: [
|
|
16715
|
+
'reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16716
|
+
'reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16717
|
+
'reductionsi({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16718
|
+
],
|
|
16719
|
+
},
|
|
16322
16720
|
'count': {
|
|
16323
16721
|
title: 'count',
|
|
16324
16722
|
category: 'Collection',
|
|
@@ -24783,30 +25181,6 @@ var predicateReference = {
|
|
|
24783
25181
|
'finite?(1.0)',
|
|
24784
25182
|
'finite?(1 / 0)',
|
|
24785
25183
|
'finite?(-1 / 0)',
|
|
24786
|
-
'finite?(sqrt(-1))',
|
|
24787
|
-
],
|
|
24788
|
-
},
|
|
24789
|
-
'nan?': {
|
|
24790
|
-
title: 'nan?',
|
|
24791
|
-
category: 'Predicate',
|
|
24792
|
-
linkName: 'nan-question',
|
|
24793
|
-
returns: {
|
|
24794
|
-
type: 'boolean',
|
|
24795
|
-
},
|
|
24796
|
-
args: {
|
|
24797
|
-
x: {
|
|
24798
|
-
type: 'number',
|
|
24799
|
-
},
|
|
24800
|
-
},
|
|
24801
|
-
variants: [
|
|
24802
|
-
{ argumentNames: ['x'] },
|
|
24803
|
-
],
|
|
24804
|
-
description: 'Returns `true` if $x is NaN (! a number), otherwise `false`.',
|
|
24805
|
-
examples: [
|
|
24806
|
-
'nan?(1.0)',
|
|
24807
|
-
'nan?(1 / 0)',
|
|
24808
|
-
'nan?(-1 / 0)',
|
|
24809
|
-
'nan?(sqrt(-1))',
|
|
24810
25184
|
],
|
|
24811
25185
|
},
|
|
24812
25186
|
'negative-infinity?': {
|
|
@@ -24829,7 +25203,6 @@ var predicateReference = {
|
|
|
24829
25203
|
'negative-infinity?(1.0)',
|
|
24830
25204
|
'negative-infinity?(1 / 0)',
|
|
24831
25205
|
'negative-infinity?(-1 / 0)',
|
|
24832
|
-
'negative-infinity?(sqrt(-1))',
|
|
24833
25206
|
],
|
|
24834
25207
|
},
|
|
24835
25208
|
'positive-infinity?': {
|
|
@@ -24852,7 +25225,6 @@ var predicateReference = {
|
|
|
24852
25225
|
'positive-infinity?(1.0)',
|
|
24853
25226
|
'positive-infinity?(1 / 0)',
|
|
24854
25227
|
'positive-infinity?(-1 / 0)',
|
|
24855
|
-
'positive-infinity?(sqrt(-1))',
|
|
24856
25228
|
],
|
|
24857
25229
|
},
|
|
24858
25230
|
'false?': {
|
|
@@ -30684,7 +31056,6 @@ var numberTheoryReference = __assign(__assign(__assign(__assign(__assign(__assig
|
|
|
30684
31056
|
'12 nth:lcm 8',
|
|
30685
31057
|
'nth:lcm(100, 25)',
|
|
30686
31058
|
'nth:lcm(37, 1)',
|
|
30687
|
-
'nth:lcm(0, 0)',
|
|
30688
31059
|
'nth:lcm(0, 5)',
|
|
30689
31060
|
'nth:lcm(5, 0)',
|
|
30690
31061
|
],
|