@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/lits.iife.js
CHANGED
|
@@ -400,6 +400,8 @@ var Lits = (function (exports) {
|
|
|
400
400
|
if (options === void 0) { options = {}; }
|
|
401
401
|
if (typeof value !== 'number')
|
|
402
402
|
return false;
|
|
403
|
+
if (Number.isNaN(value))
|
|
404
|
+
return false;
|
|
403
405
|
if (options.integer && !Number.isInteger(value))
|
|
404
406
|
return false;
|
|
405
407
|
if (options.finite && !Number.isFinite(value))
|
|
@@ -973,6 +975,35 @@ var Lits = (function (exports) {
|
|
|
973
975
|
},
|
|
974
976
|
paramCount: 2,
|
|
975
977
|
},
|
|
978
|
+
'filteri': {
|
|
979
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
980
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
981
|
+
var executeFunction = _b.executeFunction;
|
|
982
|
+
assertColl(coll, sourceCodeInfo);
|
|
983
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
984
|
+
if (Array.isArray(coll)) {
|
|
985
|
+
var result = coll.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
986
|
+
return result;
|
|
987
|
+
}
|
|
988
|
+
if (isString(coll)) {
|
|
989
|
+
return coll
|
|
990
|
+
.split('')
|
|
991
|
+
.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
992
|
+
.join('');
|
|
993
|
+
}
|
|
994
|
+
return Object.entries(coll)
|
|
995
|
+
.filter(function (_a) {
|
|
996
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
997
|
+
return executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
998
|
+
})
|
|
999
|
+
.reduce(function (result, _a) {
|
|
1000
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1001
|
+
result[key] = value;
|
|
1002
|
+
return result;
|
|
1003
|
+
}, {});
|
|
1004
|
+
},
|
|
1005
|
+
paramCount: 2,
|
|
1006
|
+
},
|
|
976
1007
|
'map': {
|
|
977
1008
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
978
1009
|
var executeFunction = _a.executeFunction;
|
|
@@ -1015,6 +1046,30 @@ var Lits = (function (exports) {
|
|
|
1015
1046
|
},
|
|
1016
1047
|
paramCount: { min: 2 },
|
|
1017
1048
|
},
|
|
1049
|
+
'mapi': {
|
|
1050
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1051
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1052
|
+
var executeFunction = _b.executeFunction;
|
|
1053
|
+
assertColl(coll, sourceCodeInfo);
|
|
1054
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1055
|
+
if (Array.isArray(coll)) {
|
|
1056
|
+
return coll.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1057
|
+
}
|
|
1058
|
+
if (isString(coll)) {
|
|
1059
|
+
return coll
|
|
1060
|
+
.split('')
|
|
1061
|
+
.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1062
|
+
.join('');
|
|
1063
|
+
}
|
|
1064
|
+
return Object.entries(coll)
|
|
1065
|
+
.reduce(function (acc, _a) {
|
|
1066
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1067
|
+
acc[key] = executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1068
|
+
return acc;
|
|
1069
|
+
}, {});
|
|
1070
|
+
},
|
|
1071
|
+
paramCount: 2,
|
|
1072
|
+
},
|
|
1018
1073
|
'reduce': {
|
|
1019
1074
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1020
1075
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1048,6 +1103,39 @@ var Lits = (function (exports) {
|
|
|
1048
1103
|
},
|
|
1049
1104
|
paramCount: 3,
|
|
1050
1105
|
},
|
|
1106
|
+
'reducei': {
|
|
1107
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1108
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1109
|
+
var executeFunction = _b.executeFunction;
|
|
1110
|
+
assertColl(coll, sourceCodeInfo);
|
|
1111
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1112
|
+
assertAny(initial, sourceCodeInfo);
|
|
1113
|
+
if (typeof coll === 'string') {
|
|
1114
|
+
assertString(initial, sourceCodeInfo);
|
|
1115
|
+
if (coll.length === 0)
|
|
1116
|
+
return initial;
|
|
1117
|
+
return coll.split('').reduce(function (result, elem, index) {
|
|
1118
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1119
|
+
}, initial);
|
|
1120
|
+
}
|
|
1121
|
+
else if (Array.isArray(coll)) {
|
|
1122
|
+
if (coll.length === 0)
|
|
1123
|
+
return initial;
|
|
1124
|
+
return coll.reduce(function (result, elem, index) {
|
|
1125
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1126
|
+
}, initial);
|
|
1127
|
+
}
|
|
1128
|
+
else {
|
|
1129
|
+
if (Object.keys(coll).length === 0)
|
|
1130
|
+
return initial;
|
|
1131
|
+
return Object.entries(coll).reduce(function (result, _a) {
|
|
1132
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1133
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1134
|
+
}, initial);
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
paramCount: 3,
|
|
1138
|
+
},
|
|
1051
1139
|
'reduce-right': {
|
|
1052
1140
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1053
1141
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1080,6 +1168,38 @@ var Lits = (function (exports) {
|
|
|
1080
1168
|
},
|
|
1081
1169
|
paramCount: 3,
|
|
1082
1170
|
},
|
|
1171
|
+
'reducei-right': {
|
|
1172
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1173
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1174
|
+
var executeFunction = _b.executeFunction;
|
|
1175
|
+
assertColl(coll, sourceCodeInfo);
|
|
1176
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1177
|
+
assertAny(initial, sourceCodeInfo);
|
|
1178
|
+
if (typeof coll === 'string') {
|
|
1179
|
+
if (coll.length === 0)
|
|
1180
|
+
return initial;
|
|
1181
|
+
return coll.split('').reduceRight(function (result, elem, index) {
|
|
1182
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1183
|
+
}, initial);
|
|
1184
|
+
}
|
|
1185
|
+
else if (Array.isArray(coll)) {
|
|
1186
|
+
if (coll.length === 0)
|
|
1187
|
+
return initial;
|
|
1188
|
+
return coll.reduceRight(function (result, elem, index) {
|
|
1189
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1190
|
+
}, initial);
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
if (Object.keys(coll).length === 0)
|
|
1194
|
+
return initial;
|
|
1195
|
+
return Object.entries(coll).reduceRight(function (result, _a) {
|
|
1196
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1197
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1198
|
+
}, initial);
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1201
|
+
paramCount: 3,
|
|
1202
|
+
},
|
|
1083
1203
|
'reductions': {
|
|
1084
1204
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1085
1205
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1126,6 +1246,52 @@ var Lits = (function (exports) {
|
|
|
1126
1246
|
},
|
|
1127
1247
|
paramCount: 3,
|
|
1128
1248
|
},
|
|
1249
|
+
'reductionsi': {
|
|
1250
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1251
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1252
|
+
var executeFunction = _b.executeFunction;
|
|
1253
|
+
assertColl(coll, sourceCodeInfo);
|
|
1254
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1255
|
+
assertAny(initial, sourceCodeInfo);
|
|
1256
|
+
assertAny(initial, sourceCodeInfo);
|
|
1257
|
+
if (typeof coll === 'string') {
|
|
1258
|
+
assertString(initial, sourceCodeInfo);
|
|
1259
|
+
if (coll.length === 0)
|
|
1260
|
+
return [initial];
|
|
1261
|
+
var resultArray_4 = [initial];
|
|
1262
|
+
coll.split('').reduce(function (result, elem, index) {
|
|
1263
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1264
|
+
resultArray_4.push(newVal);
|
|
1265
|
+
return newVal;
|
|
1266
|
+
}, initial);
|
|
1267
|
+
return resultArray_4;
|
|
1268
|
+
}
|
|
1269
|
+
else if (Array.isArray(coll)) {
|
|
1270
|
+
if (coll.length === 0)
|
|
1271
|
+
return [initial];
|
|
1272
|
+
var resultArray_5 = [initial];
|
|
1273
|
+
coll.reduce(function (result, elem, index) {
|
|
1274
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1275
|
+
resultArray_5.push(newVal);
|
|
1276
|
+
return newVal;
|
|
1277
|
+
}, initial);
|
|
1278
|
+
return resultArray_5;
|
|
1279
|
+
}
|
|
1280
|
+
else {
|
|
1281
|
+
if (Object.keys(coll).length === 0)
|
|
1282
|
+
return [initial];
|
|
1283
|
+
var resultArray_6 = [initial];
|
|
1284
|
+
Object.entries(coll).reduce(function (result, _a) {
|
|
1285
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1286
|
+
var newVal = executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1287
|
+
resultArray_6.push(newVal);
|
|
1288
|
+
return newVal;
|
|
1289
|
+
}, initial);
|
|
1290
|
+
return resultArray_6;
|
|
1291
|
+
}
|
|
1292
|
+
},
|
|
1293
|
+
paramCount: 3,
|
|
1294
|
+
},
|
|
1129
1295
|
'get': {
|
|
1130
1296
|
evaluate: function (params, sourceCodeInfo) {
|
|
1131
1297
|
var _a = __read(params, 2), coll = _a[0], key = _a[1];
|
|
@@ -1379,7 +1545,7 @@ var Lits = (function (exports) {
|
|
|
1379
1545
|
};
|
|
1380
1546
|
|
|
1381
1547
|
var arrayNormalExpression = {
|
|
1382
|
-
range: {
|
|
1548
|
+
'range': {
|
|
1383
1549
|
evaluate: function (params, sourceCodeInfo) {
|
|
1384
1550
|
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
1385
1551
|
var from;
|
|
@@ -1417,7 +1583,7 @@ var Lits = (function (exports) {
|
|
|
1417
1583
|
},
|
|
1418
1584
|
paramCount: { min: 1, max: 3 },
|
|
1419
1585
|
},
|
|
1420
|
-
repeat: {
|
|
1586
|
+
'repeat': {
|
|
1421
1587
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1422
1588
|
var _b = __read(_a, 2), value = _b[0], count = _b[1];
|
|
1423
1589
|
assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
@@ -1428,7 +1594,7 @@ var Lits = (function (exports) {
|
|
|
1428
1594
|
},
|
|
1429
1595
|
paramCount: 2,
|
|
1430
1596
|
},
|
|
1431
|
-
flatten: {
|
|
1597
|
+
'flatten': {
|
|
1432
1598
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1433
1599
|
var _b = __read(_a, 2), seq = _b[0], depth = _b[1];
|
|
1434
1600
|
assertArray(seq, sourceCodeInfo);
|
|
@@ -1439,7 +1605,7 @@ var Lits = (function (exports) {
|
|
|
1439
1605
|
},
|
|
1440
1606
|
paramCount: { min: 1, max: 2 },
|
|
1441
1607
|
},
|
|
1442
|
-
mapcat: {
|
|
1608
|
+
'mapcat': {
|
|
1443
1609
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1444
1610
|
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1445
1611
|
var executeFunction = _b.executeFunction;
|
|
@@ -1449,6 +1615,38 @@ var Lits = (function (exports) {
|
|
|
1449
1615
|
},
|
|
1450
1616
|
paramCount: 2,
|
|
1451
1617
|
},
|
|
1618
|
+
'moving-fn': {
|
|
1619
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1620
|
+
var _c = __read(_a, 3), arr = _c[0], windowSize = _c[1], fn = _c[2];
|
|
1621
|
+
var executeFunction = _b.executeFunction;
|
|
1622
|
+
assertArray(arr, sourceCodeInfo);
|
|
1623
|
+
assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length });
|
|
1624
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1625
|
+
var result = [];
|
|
1626
|
+
for (var i = 0; i <= arr.length - windowSize; i++) {
|
|
1627
|
+
var window_1 = arr.slice(i, i + windowSize);
|
|
1628
|
+
var value = executeFunction(fn, [window_1], contextStack, sourceCodeInfo);
|
|
1629
|
+
result.push(value);
|
|
1630
|
+
}
|
|
1631
|
+
return result;
|
|
1632
|
+
},
|
|
1633
|
+
paramCount: 3,
|
|
1634
|
+
},
|
|
1635
|
+
'running-fn': {
|
|
1636
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1637
|
+
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1638
|
+
var executeFunction = _b.executeFunction;
|
|
1639
|
+
assertArray(arr, sourceCodeInfo);
|
|
1640
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1641
|
+
var result = [];
|
|
1642
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
1643
|
+
var subArr = arr.slice(0, i + 1);
|
|
1644
|
+
result.push(executeFunction(fn, [subArr], contextStack, sourceCodeInfo));
|
|
1645
|
+
}
|
|
1646
|
+
return result;
|
|
1647
|
+
},
|
|
1648
|
+
paramCount: 2,
|
|
1649
|
+
},
|
|
1452
1650
|
};
|
|
1453
1651
|
|
|
1454
1652
|
var sequenceNormalExpression = {
|
|
@@ -2180,7 +2378,7 @@ var Lits = (function (exports) {
|
|
|
2180
2378
|
if (vectors.has(vector)) {
|
|
2181
2379
|
return true;
|
|
2182
2380
|
}
|
|
2183
|
-
if (vector.every(function (elem) { return isNumber(elem
|
|
2381
|
+
if (vector.every(function (elem) { return isNumber(elem); })) {
|
|
2184
2382
|
annotatedArrays.add(vector);
|
|
2185
2383
|
vectors.add(vector);
|
|
2186
2384
|
return true;
|
|
@@ -2289,7 +2487,7 @@ var Lits = (function (exports) {
|
|
|
2289
2487
|
if (row.length !== nbrOfCols) {
|
|
2290
2488
|
return false;
|
|
2291
2489
|
}
|
|
2292
|
-
if (row.some(function (cell) { return !isNumber(cell
|
|
2490
|
+
if (row.some(function (cell) { return !isNumber(cell); })) {
|
|
2293
2491
|
return false;
|
|
2294
2492
|
}
|
|
2295
2493
|
}
|
|
@@ -3822,14 +4020,6 @@ var Lits = (function (exports) {
|
|
|
3822
4020
|
},
|
|
3823
4021
|
paramCount: 1,
|
|
3824
4022
|
},
|
|
3825
|
-
'nan?': {
|
|
3826
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
3827
|
-
var _b = __read(_a, 1), value = _b[0];
|
|
3828
|
-
assertNumber(value, sourceCodeInfo);
|
|
3829
|
-
return Number.isNaN(value);
|
|
3830
|
-
},
|
|
3831
|
-
paramCount: 1,
|
|
3832
|
-
},
|
|
3833
4023
|
'positive-infinity?': {
|
|
3834
4024
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3835
4025
|
var _b = __read(_a, 1), value = _b[0];
|
|
@@ -12546,8 +12736,13 @@ var Lits = (function (exports) {
|
|
|
12546
12736
|
return contextStack.evaluateSymbol(node);
|
|
12547
12737
|
case NodeTypes.ReservedSymbol:
|
|
12548
12738
|
return evaluateReservedSymbol(node);
|
|
12549
|
-
case NodeTypes.NormalExpression:
|
|
12550
|
-
|
|
12739
|
+
case NodeTypes.NormalExpression: {
|
|
12740
|
+
var result = evaluateNormalExpression(node, contextStack);
|
|
12741
|
+
if (typeof result === 'number' && Number.isNaN(result)) {
|
|
12742
|
+
throw new LitsError('Number is NaN', node[2]);
|
|
12743
|
+
}
|
|
12744
|
+
return annotate(result);
|
|
12745
|
+
}
|
|
12551
12746
|
case NodeTypes.SpecialExpression:
|
|
12552
12747
|
return annotate(evaluateSpecialExpression(node, contextStack));
|
|
12553
12748
|
/* v8 ignore next 2 */
|
|
@@ -14953,10 +15148,15 @@ var Lits = (function (exports) {
|
|
|
14953
15148
|
var api = {
|
|
14954
15149
|
collection: [
|
|
14955
15150
|
'filter',
|
|
15151
|
+
'filteri',
|
|
14956
15152
|
'map',
|
|
15153
|
+
'mapi',
|
|
14957
15154
|
'reduce',
|
|
15155
|
+
'reducei',
|
|
14958
15156
|
'reduce-right',
|
|
15157
|
+
'reducei-right',
|
|
14959
15158
|
'reductions',
|
|
15159
|
+
'reductionsi',
|
|
14960
15160
|
'count',
|
|
14961
15161
|
'get',
|
|
14962
15162
|
'get-in',
|
|
@@ -14977,6 +15177,8 @@ var Lits = (function (exports) {
|
|
|
14977
15177
|
'repeat',
|
|
14978
15178
|
'flatten',
|
|
14979
15179
|
'mapcat',
|
|
15180
|
+
'moving-fn',
|
|
15181
|
+
'running-fn',
|
|
14980
15182
|
],
|
|
14981
15183
|
sequence: [
|
|
14982
15184
|
'nth',
|
|
@@ -15116,7 +15318,6 @@ var Lits = (function (exports) {
|
|
|
15116
15318
|
'even?',
|
|
15117
15319
|
'odd?',
|
|
15118
15320
|
'finite?',
|
|
15119
|
-
'nan?',
|
|
15120
15321
|
'negative-infinity?',
|
|
15121
15322
|
'positive-infinity?',
|
|
15122
15323
|
'false?',
|
|
@@ -15453,7 +15654,7 @@ var Lits = (function (exports) {
|
|
|
15453
15654
|
}
|
|
15454
15655
|
|
|
15455
15656
|
var arrayReference = {
|
|
15456
|
-
range: {
|
|
15657
|
+
'range': {
|
|
15457
15658
|
title: 'range',
|
|
15458
15659
|
category: 'Array',
|
|
15459
15660
|
linkName: 'range',
|
|
@@ -15478,7 +15679,7 @@ var Lits = (function (exports) {
|
|
|
15478
15679
|
"\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)",
|
|
15479
15680
|
],
|
|
15480
15681
|
},
|
|
15481
|
-
repeat: {
|
|
15682
|
+
'repeat': {
|
|
15482
15683
|
title: 'repeat',
|
|
15483
15684
|
category: 'Array',
|
|
15484
15685
|
linkName: 'repeat',
|
|
@@ -15497,7 +15698,7 @@ var Lits = (function (exports) {
|
|
|
15497
15698
|
'"Albert" repeat 5',
|
|
15498
15699
|
],
|
|
15499
15700
|
},
|
|
15500
|
-
flatten: {
|
|
15701
|
+
'flatten': {
|
|
15501
15702
|
title: 'flatten',
|
|
15502
15703
|
category: 'Array',
|
|
15503
15704
|
linkName: 'flatten',
|
|
@@ -15521,7 +15722,7 @@ var Lits = (function (exports) {
|
|
|
15521
15722
|
],
|
|
15522
15723
|
noOperatorDocumentation: true,
|
|
15523
15724
|
},
|
|
15524
|
-
mapcat: {
|
|
15725
|
+
'mapcat': {
|
|
15525
15726
|
title: 'mapcat',
|
|
15526
15727
|
category: 'Array',
|
|
15527
15728
|
linkName: 'mapcat',
|
|
@@ -15546,6 +15747,60 @@ var Lits = (function (exports) {
|
|
|
15546
15747
|
"\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
|
|
15547
15748
|
],
|
|
15548
15749
|
},
|
|
15750
|
+
'moving-fn': {
|
|
15751
|
+
title: 'moving-fn',
|
|
15752
|
+
category: 'Array',
|
|
15753
|
+
linkName: 'moving-fn',
|
|
15754
|
+
returns: {
|
|
15755
|
+
type: 'array',
|
|
15756
|
+
},
|
|
15757
|
+
args: {
|
|
15758
|
+
arr: {
|
|
15759
|
+
type: 'array',
|
|
15760
|
+
},
|
|
15761
|
+
windowSize: {
|
|
15762
|
+
type: 'number',
|
|
15763
|
+
description: 'The size of the moving window.',
|
|
15764
|
+
},
|
|
15765
|
+
fn: {
|
|
15766
|
+
type: 'function',
|
|
15767
|
+
},
|
|
15768
|
+
},
|
|
15769
|
+
variants: [{
|
|
15770
|
+
argumentNames: ['arr', 'windowSize', 'fn'],
|
|
15771
|
+
}],
|
|
15772
|
+
description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',
|
|
15773
|
+
examples: [
|
|
15774
|
+
'moving-fn([1, 2, 3], 2, vec:sum)',
|
|
15775
|
+
'moving-fn([1, 2, 3], 1, vec:sum)',
|
|
15776
|
+
'moving-fn([1, 2, 3], 3, vec:sum)',
|
|
15777
|
+
],
|
|
15778
|
+
},
|
|
15779
|
+
'running-fn': {
|
|
15780
|
+
title: 'running-fn',
|
|
15781
|
+
category: 'Array',
|
|
15782
|
+
linkName: 'running-fn',
|
|
15783
|
+
returns: {
|
|
15784
|
+
type: 'array',
|
|
15785
|
+
},
|
|
15786
|
+
args: {
|
|
15787
|
+
a: {
|
|
15788
|
+
type: 'array',
|
|
15789
|
+
},
|
|
15790
|
+
b: {
|
|
15791
|
+
type: 'function',
|
|
15792
|
+
},
|
|
15793
|
+
},
|
|
15794
|
+
variants: [{
|
|
15795
|
+
argumentNames: ['a', 'b'],
|
|
15796
|
+
}],
|
|
15797
|
+
description: 'Returns the result of applying $b to each element of $a.',
|
|
15798
|
+
examples: [
|
|
15799
|
+
'running-fn([1, 2, 3], vec:sum)',
|
|
15800
|
+
'running-fn([1, 2, 3], vec:max)',
|
|
15801
|
+
'running-fn([1, 2, 3], vec:min)',
|
|
15802
|
+
],
|
|
15803
|
+
},
|
|
15549
15804
|
};
|
|
15550
15805
|
|
|
15551
15806
|
var assertReference = {
|
|
@@ -16206,6 +16461,32 @@ var Lits = (function (exports) {
|
|
|
16206
16461
|
"\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
|
|
16207
16462
|
],
|
|
16208
16463
|
},
|
|
16464
|
+
'filteri': {
|
|
16465
|
+
title: 'filteri',
|
|
16466
|
+
category: 'Collection',
|
|
16467
|
+
linkName: 'filteri',
|
|
16468
|
+
returns: {
|
|
16469
|
+
type: 'collection',
|
|
16470
|
+
},
|
|
16471
|
+
args: {
|
|
16472
|
+
a: {
|
|
16473
|
+
type: 'collection',
|
|
16474
|
+
},
|
|
16475
|
+
b: {
|
|
16476
|
+
type: 'function',
|
|
16477
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16478
|
+
},
|
|
16479
|
+
},
|
|
16480
|
+
variants: [
|
|
16481
|
+
{ argumentNames: ['a', 'b'] },
|
|
16482
|
+
],
|
|
16483
|
+
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.',
|
|
16484
|
+
examples: [
|
|
16485
|
+
'filteri([1, 2, 3], (x, i) -> i % 2 = 0)',
|
|
16486
|
+
'filteri([1, 2, 3], (x, i) -> x % 2 = 0)',
|
|
16487
|
+
'filteri([1, 2, 3], (x, i) -> x + i > 3)',
|
|
16488
|
+
],
|
|
16489
|
+
},
|
|
16209
16490
|
'map': {
|
|
16210
16491
|
title: 'map',
|
|
16211
16492
|
category: 'Collection',
|
|
@@ -16234,6 +16515,34 @@ var Lits = (function (exports) {
|
|
|
16234
16515
|
'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
|
|
16235
16516
|
],
|
|
16236
16517
|
},
|
|
16518
|
+
'mapi': {
|
|
16519
|
+
title: 'mapi',
|
|
16520
|
+
category: 'Collection',
|
|
16521
|
+
linkName: 'mapi',
|
|
16522
|
+
returns: {
|
|
16523
|
+
type: 'collection',
|
|
16524
|
+
},
|
|
16525
|
+
args: {
|
|
16526
|
+
a: {
|
|
16527
|
+
type: 'collection',
|
|
16528
|
+
},
|
|
16529
|
+
b: {
|
|
16530
|
+
type: 'function',
|
|
16531
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16532
|
+
},
|
|
16533
|
+
},
|
|
16534
|
+
variants: [
|
|
16535
|
+
{ argumentNames: ['a', 'b'] },
|
|
16536
|
+
],
|
|
16537
|
+
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.',
|
|
16538
|
+
examples: [
|
|
16539
|
+
'mapi([1, 2, 3], (x, i) -> x + i)',
|
|
16540
|
+
'mapi([1, 2, 3], (x, i) -> x * i)',
|
|
16541
|
+
'mapi([1, 2, 3], (x, i) -> x - i)',
|
|
16542
|
+
'mapi([1, 2, 3], (x, i) -> x / i)',
|
|
16543
|
+
'mapi([1, 2, 3], (x, i) -> x % inc(i))',
|
|
16544
|
+
],
|
|
16545
|
+
},
|
|
16237
16546
|
'reduce': {
|
|
16238
16547
|
title: 'reduce',
|
|
16239
16548
|
category: 'Collection',
|
|
@@ -16290,12 +16599,73 @@ var Lits = (function (exports) {
|
|
|
16290
16599
|
'reduce-right({ a := 1, b := 2 }, +, 0)',
|
|
16291
16600
|
],
|
|
16292
16601
|
},
|
|
16602
|
+
'reducei-right': {
|
|
16603
|
+
title: 'reducei-right',
|
|
16604
|
+
category: 'Collection',
|
|
16605
|
+
linkName: 'reducei-right',
|
|
16606
|
+
returns: {
|
|
16607
|
+
type: 'any',
|
|
16608
|
+
},
|
|
16609
|
+
args: {
|
|
16610
|
+
coll: {
|
|
16611
|
+
type: 'collection',
|
|
16612
|
+
},
|
|
16613
|
+
fun: {
|
|
16614
|
+
type: 'function',
|
|
16615
|
+
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.',
|
|
16616
|
+
},
|
|
16617
|
+
initial: {
|
|
16618
|
+
type: 'any',
|
|
16619
|
+
description: 'The initial value to use as the accumulator.',
|
|
16620
|
+
},
|
|
16621
|
+
},
|
|
16622
|
+
variants: [
|
|
16623
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16624
|
+
],
|
|
16625
|
+
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.',
|
|
16626
|
+
examples: [
|
|
16627
|
+
'reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16628
|
+
'reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16629
|
+
'reducei-right({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16630
|
+
],
|
|
16631
|
+
},
|
|
16632
|
+
'reducei': {
|
|
16633
|
+
title: 'reducei',
|
|
16634
|
+
category: 'Collection',
|
|
16635
|
+
linkName: 'reducei',
|
|
16636
|
+
returns: {
|
|
16637
|
+
type: 'any',
|
|
16638
|
+
},
|
|
16639
|
+
args: {
|
|
16640
|
+
coll: {
|
|
16641
|
+
type: 'collection',
|
|
16642
|
+
},
|
|
16643
|
+
fun: {
|
|
16644
|
+
type: 'function',
|
|
16645
|
+
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.',
|
|
16646
|
+
},
|
|
16647
|
+
initial: {
|
|
16648
|
+
type: 'any',
|
|
16649
|
+
description: 'The initial value to use as the accumulator.',
|
|
16650
|
+
},
|
|
16651
|
+
},
|
|
16652
|
+
variants: [
|
|
16653
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16654
|
+
],
|
|
16655
|
+
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.',
|
|
16656
|
+
examples: [
|
|
16657
|
+
'reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16658
|
+
'reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16659
|
+
'reducei({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16660
|
+
],
|
|
16661
|
+
},
|
|
16293
16662
|
'reductions': {
|
|
16294
16663
|
title: 'reductions',
|
|
16295
16664
|
category: 'Collection',
|
|
16296
16665
|
linkName: 'reductions',
|
|
16297
16666
|
returns: {
|
|
16298
16667
|
type: 'any',
|
|
16668
|
+
array: true,
|
|
16299
16669
|
},
|
|
16300
16670
|
args: {
|
|
16301
16671
|
fun: {
|
|
@@ -16320,6 +16690,37 @@ var Lits = (function (exports) {
|
|
|
16320
16690
|
"\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)",
|
|
16321
16691
|
],
|
|
16322
16692
|
},
|
|
16693
|
+
'reductionsi': {
|
|
16694
|
+
title: 'reductionsi',
|
|
16695
|
+
category: 'Collection',
|
|
16696
|
+
linkName: 'reductionsi',
|
|
16697
|
+
returns: {
|
|
16698
|
+
type: 'any',
|
|
16699
|
+
array: true,
|
|
16700
|
+
},
|
|
16701
|
+
args: {
|
|
16702
|
+
coll: {
|
|
16703
|
+
type: 'collection',
|
|
16704
|
+
},
|
|
16705
|
+
fun: {
|
|
16706
|
+
type: 'function',
|
|
16707
|
+
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.',
|
|
16708
|
+
},
|
|
16709
|
+
initial: {
|
|
16710
|
+
type: 'any',
|
|
16711
|
+
description: 'The initial value to use as the accumulator.',
|
|
16712
|
+
},
|
|
16713
|
+
},
|
|
16714
|
+
variants: [
|
|
16715
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16716
|
+
],
|
|
16717
|
+
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.',
|
|
16718
|
+
examples: [
|
|
16719
|
+
'reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16720
|
+
'reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16721
|
+
'reductionsi({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16722
|
+
],
|
|
16723
|
+
},
|
|
16323
16724
|
'count': {
|
|
16324
16725
|
title: 'count',
|
|
16325
16726
|
category: 'Collection',
|
|
@@ -24784,30 +25185,6 @@ var Lits = (function (exports) {
|
|
|
24784
25185
|
'finite?(1.0)',
|
|
24785
25186
|
'finite?(1 / 0)',
|
|
24786
25187
|
'finite?(-1 / 0)',
|
|
24787
|
-
'finite?(sqrt(-1))',
|
|
24788
|
-
],
|
|
24789
|
-
},
|
|
24790
|
-
'nan?': {
|
|
24791
|
-
title: 'nan?',
|
|
24792
|
-
category: 'Predicate',
|
|
24793
|
-
linkName: 'nan-question',
|
|
24794
|
-
returns: {
|
|
24795
|
-
type: 'boolean',
|
|
24796
|
-
},
|
|
24797
|
-
args: {
|
|
24798
|
-
x: {
|
|
24799
|
-
type: 'number',
|
|
24800
|
-
},
|
|
24801
|
-
},
|
|
24802
|
-
variants: [
|
|
24803
|
-
{ argumentNames: ['x'] },
|
|
24804
|
-
],
|
|
24805
|
-
description: 'Returns `true` if $x is NaN (! a number), otherwise `false`.',
|
|
24806
|
-
examples: [
|
|
24807
|
-
'nan?(1.0)',
|
|
24808
|
-
'nan?(1 / 0)',
|
|
24809
|
-
'nan?(-1 / 0)',
|
|
24810
|
-
'nan?(sqrt(-1))',
|
|
24811
25188
|
],
|
|
24812
25189
|
},
|
|
24813
25190
|
'negative-infinity?': {
|
|
@@ -24830,7 +25207,6 @@ var Lits = (function (exports) {
|
|
|
24830
25207
|
'negative-infinity?(1.0)',
|
|
24831
25208
|
'negative-infinity?(1 / 0)',
|
|
24832
25209
|
'negative-infinity?(-1 / 0)',
|
|
24833
|
-
'negative-infinity?(sqrt(-1))',
|
|
24834
25210
|
],
|
|
24835
25211
|
},
|
|
24836
25212
|
'positive-infinity?': {
|
|
@@ -24853,7 +25229,6 @@ var Lits = (function (exports) {
|
|
|
24853
25229
|
'positive-infinity?(1.0)',
|
|
24854
25230
|
'positive-infinity?(1 / 0)',
|
|
24855
25231
|
'positive-infinity?(-1 / 0)',
|
|
24856
|
-
'positive-infinity?(sqrt(-1))',
|
|
24857
25232
|
],
|
|
24858
25233
|
},
|
|
24859
25234
|
'false?': {
|
|
@@ -30685,7 +31060,6 @@ var Lits = (function (exports) {
|
|
|
30685
31060
|
'12 nth:lcm 8',
|
|
30686
31061
|
'nth:lcm(100, 25)',
|
|
30687
31062
|
'nth:lcm(37, 1)',
|
|
30688
|
-
'nth:lcm(0, 0)',
|
|
30689
31063
|
'nth:lcm(0, 5)',
|
|
30690
31064
|
'nth:lcm(5, 0)',
|
|
30691
31065
|
],
|