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