@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/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, { finite: true }); })) {
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, { finite: true }); })) {
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];
@@ -12545,8 +12735,13 @@ function evaluateNode(node, contextStack) {
12545
12735
  return contextStack.evaluateSymbol(node);
12546
12736
  case NodeTypes.ReservedSymbol:
12547
12737
  return evaluateReservedSymbol(node);
12548
- case NodeTypes.NormalExpression:
12549
- return annotate(evaluateNormalExpression(node, contextStack));
12738
+ case NodeTypes.NormalExpression: {
12739
+ var result = evaluateNormalExpression(node, contextStack);
12740
+ if (typeof result === 'number' && Number.isNaN(result)) {
12741
+ throw new LitsError('Number is NaN', node[2]);
12742
+ }
12743
+ return annotate(result);
12744
+ }
12550
12745
  case NodeTypes.SpecialExpression:
12551
12746
  return annotate(evaluateSpecialExpression(node, contextStack));
12552
12747
  /* v8 ignore next 2 */
@@ -14952,10 +15147,15 @@ function getVectorReductionNames(name) {
14952
15147
  var api = {
14953
15148
  collection: [
14954
15149
  'filter',
15150
+ 'filteri',
14955
15151
  'map',
15152
+ 'mapi',
14956
15153
  'reduce',
15154
+ 'reducei',
14957
15155
  'reduce-right',
15156
+ 'reducei-right',
14958
15157
  'reductions',
15158
+ 'reductionsi',
14959
15159
  'count',
14960
15160
  'get',
14961
15161
  'get-in',
@@ -14976,6 +15176,8 @@ var api = {
14976
15176
  'repeat',
14977
15177
  'flatten',
14978
15178
  'mapcat',
15179
+ 'moving-fn',
15180
+ 'running-fn',
14979
15181
  ],
14980
15182
  sequence: [
14981
15183
  'nth',
@@ -15115,7 +15317,6 @@ var api = {
15115
15317
  'even?',
15116
15318
  'odd?',
15117
15319
  'finite?',
15118
- 'nan?',
15119
15320
  'negative-infinity?',
15120
15321
  'positive-infinity?',
15121
15322
  'false?',
@@ -15452,7 +15653,7 @@ function getOperatorArgs(a, b) {
15452
15653
  }
15453
15654
 
15454
15655
  var arrayReference = {
15455
- range: {
15656
+ 'range': {
15456
15657
  title: 'range',
15457
15658
  category: 'Array',
15458
15659
  linkName: 'range',
@@ -15477,7 +15678,7 @@ var arrayReference = {
15477
15678
  "\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)",
15478
15679
  ],
15479
15680
  },
15480
- repeat: {
15681
+ 'repeat': {
15481
15682
  title: 'repeat',
15482
15683
  category: 'Array',
15483
15684
  linkName: 'repeat',
@@ -15496,7 +15697,7 @@ var arrayReference = {
15496
15697
  '"Albert" repeat 5',
15497
15698
  ],
15498
15699
  },
15499
- flatten: {
15700
+ 'flatten': {
15500
15701
  title: 'flatten',
15501
15702
  category: 'Array',
15502
15703
  linkName: 'flatten',
@@ -15520,7 +15721,7 @@ var arrayReference = {
15520
15721
  ],
15521
15722
  noOperatorDocumentation: true,
15522
15723
  },
15523
- mapcat: {
15724
+ 'mapcat': {
15524
15725
  title: 'mapcat',
15525
15726
  category: 'Array',
15526
15727
  linkName: 'mapcat',
@@ -15545,6 +15746,60 @@ var arrayReference = {
15545
15746
  "\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
15546
15747
  ],
15547
15748
  },
15749
+ 'moving-fn': {
15750
+ title: 'moving-fn',
15751
+ category: 'Array',
15752
+ linkName: 'moving-fn',
15753
+ returns: {
15754
+ type: 'array',
15755
+ },
15756
+ args: {
15757
+ arr: {
15758
+ type: 'array',
15759
+ },
15760
+ windowSize: {
15761
+ type: 'number',
15762
+ description: 'The size of the moving window.',
15763
+ },
15764
+ fn: {
15765
+ type: 'function',
15766
+ },
15767
+ },
15768
+ variants: [{
15769
+ argumentNames: ['arr', 'windowSize', 'fn'],
15770
+ }],
15771
+ description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',
15772
+ examples: [
15773
+ 'moving-fn([1, 2, 3], 2, vec:sum)',
15774
+ 'moving-fn([1, 2, 3], 1, vec:sum)',
15775
+ 'moving-fn([1, 2, 3], 3, vec:sum)',
15776
+ ],
15777
+ },
15778
+ 'running-fn': {
15779
+ title: 'running-fn',
15780
+ category: 'Array',
15781
+ linkName: 'running-fn',
15782
+ returns: {
15783
+ type: 'array',
15784
+ },
15785
+ args: {
15786
+ a: {
15787
+ type: 'array',
15788
+ },
15789
+ b: {
15790
+ type: 'function',
15791
+ },
15792
+ },
15793
+ variants: [{
15794
+ argumentNames: ['a', 'b'],
15795
+ }],
15796
+ description: 'Returns the result of applying $b to each element of $a.',
15797
+ examples: [
15798
+ 'running-fn([1, 2, 3], vec:sum)',
15799
+ 'running-fn([1, 2, 3], vec:max)',
15800
+ 'running-fn([1, 2, 3], vec:min)',
15801
+ ],
15802
+ },
15548
15803
  };
15549
15804
 
15550
15805
  var assertReference = {
@@ -16205,6 +16460,32 @@ var collectionReference = {
16205
16460
  "\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
16206
16461
  ],
16207
16462
  },
16463
+ 'filteri': {
16464
+ title: 'filteri',
16465
+ category: 'Collection',
16466
+ linkName: 'filteri',
16467
+ returns: {
16468
+ type: 'collection',
16469
+ },
16470
+ args: {
16471
+ a: {
16472
+ type: 'collection',
16473
+ },
16474
+ b: {
16475
+ type: 'function',
16476
+ description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
16477
+ },
16478
+ },
16479
+ variants: [
16480
+ { argumentNames: ['a', 'b'] },
16481
+ ],
16482
+ 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.',
16483
+ examples: [
16484
+ 'filteri([1, 2, 3], (x, i) -> i % 2 = 0)',
16485
+ 'filteri([1, 2, 3], (x, i) -> x % 2 = 0)',
16486
+ 'filteri([1, 2, 3], (x, i) -> x + i > 3)',
16487
+ ],
16488
+ },
16208
16489
  'map': {
16209
16490
  title: 'map',
16210
16491
  category: 'Collection',
@@ -16233,6 +16514,34 @@ var collectionReference = {
16233
16514
  'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
16234
16515
  ],
16235
16516
  },
16517
+ 'mapi': {
16518
+ title: 'mapi',
16519
+ category: 'Collection',
16520
+ linkName: 'mapi',
16521
+ returns: {
16522
+ type: 'collection',
16523
+ },
16524
+ args: {
16525
+ a: {
16526
+ type: 'collection',
16527
+ },
16528
+ b: {
16529
+ type: 'function',
16530
+ description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
16531
+ },
16532
+ },
16533
+ variants: [
16534
+ { argumentNames: ['a', 'b'] },
16535
+ ],
16536
+ 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.',
16537
+ examples: [
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 - i)',
16541
+ 'mapi([1, 2, 3], (x, i) -> x / i)',
16542
+ 'mapi([1, 2, 3], (x, i) -> x % inc(i))',
16543
+ ],
16544
+ },
16236
16545
  'reduce': {
16237
16546
  title: 'reduce',
16238
16547
  category: 'Collection',
@@ -16289,12 +16598,73 @@ var collectionReference = {
16289
16598
  'reduce-right({ a := 1, b := 2 }, +, 0)',
16290
16599
  ],
16291
16600
  },
16601
+ 'reducei-right': {
16602
+ title: 'reducei-right',
16603
+ category: 'Collection',
16604
+ linkName: 'reducei-right',
16605
+ returns: {
16606
+ type: 'any',
16607
+ },
16608
+ args: {
16609
+ coll: {
16610
+ type: 'collection',
16611
+ },
16612
+ fun: {
16613
+ type: 'function',
16614
+ 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.',
16615
+ },
16616
+ initial: {
16617
+ type: 'any',
16618
+ description: 'The initial value to use as the accumulator.',
16619
+ },
16620
+ },
16621
+ variants: [
16622
+ { argumentNames: ['coll', 'fun', 'initial'] },
16623
+ ],
16624
+ 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.',
16625
+ examples: [
16626
+ 'reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
16627
+ 'reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
16628
+ 'reducei-right({ a := 1, b := 2 }, -> $1 ++ $3, "")',
16629
+ ],
16630
+ },
16631
+ 'reducei': {
16632
+ title: 'reducei',
16633
+ category: 'Collection',
16634
+ linkName: 'reducei',
16635
+ returns: {
16636
+ type: 'any',
16637
+ },
16638
+ args: {
16639
+ coll: {
16640
+ type: 'collection',
16641
+ },
16642
+ fun: {
16643
+ type: 'function',
16644
+ 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.',
16645
+ },
16646
+ initial: {
16647
+ type: 'any',
16648
+ description: 'The initial value to use as the accumulator.',
16649
+ },
16650
+ },
16651
+ variants: [
16652
+ { argumentNames: ['coll', 'fun', 'initial'] },
16653
+ ],
16654
+ 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.',
16655
+ examples: [
16656
+ 'reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
16657
+ 'reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
16658
+ 'reducei({ a := 1, b := 2 }, -> $1 ++ $3, "")',
16659
+ ],
16660
+ },
16292
16661
  'reductions': {
16293
16662
  title: 'reductions',
16294
16663
  category: 'Collection',
16295
16664
  linkName: 'reductions',
16296
16665
  returns: {
16297
16666
  type: 'any',
16667
+ array: true,
16298
16668
  },
16299
16669
  args: {
16300
16670
  fun: {
@@ -16319,6 +16689,37 @@ var collectionReference = {
16319
16689
  "\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
16690
  ],
16321
16691
  },
16692
+ 'reductionsi': {
16693
+ title: 'reductionsi',
16694
+ category: 'Collection',
16695
+ linkName: 'reductionsi',
16696
+ returns: {
16697
+ type: 'any',
16698
+ array: true,
16699
+ },
16700
+ args: {
16701
+ coll: {
16702
+ type: 'collection',
16703
+ },
16704
+ fun: {
16705
+ type: 'function',
16706
+ 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.',
16707
+ },
16708
+ initial: {
16709
+ type: 'any',
16710
+ description: 'The initial value to use as the accumulator.',
16711
+ },
16712
+ },
16713
+ variants: [
16714
+ { argumentNames: ['coll', 'fun', 'initial'] },
16715
+ ],
16716
+ 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.',
16717
+ examples: [
16718
+ 'reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
16719
+ 'reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
16720
+ 'reductionsi({ a := 1, b := 2 }, -> $1 ++ $3, "")',
16721
+ ],
16722
+ },
16322
16723
  'count': {
16323
16724
  title: 'count',
16324
16725
  category: 'Collection',
@@ -24783,30 +25184,6 @@ var predicateReference = {
24783
25184
  'finite?(1.0)',
24784
25185
  'finite?(1 / 0)',
24785
25186
  '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
25187
  ],
24811
25188
  },
24812
25189
  'negative-infinity?': {
@@ -24829,7 +25206,6 @@ var predicateReference = {
24829
25206
  'negative-infinity?(1.0)',
24830
25207
  'negative-infinity?(1 / 0)',
24831
25208
  'negative-infinity?(-1 / 0)',
24832
- 'negative-infinity?(sqrt(-1))',
24833
25209
  ],
24834
25210
  },
24835
25211
  'positive-infinity?': {
@@ -24852,7 +25228,6 @@ var predicateReference = {
24852
25228
  'positive-infinity?(1.0)',
24853
25229
  'positive-infinity?(1 / 0)',
24854
25230
  'positive-infinity?(-1 / 0)',
24855
- 'positive-infinity?(sqrt(-1))',
24856
25231
  ],
24857
25232
  },
24858
25233
  'false?': {
@@ -30684,7 +31059,6 @@ var numberTheoryReference = __assign(__assign(__assign(__assign(__assign(__assig
30684
31059
  '12 nth:lcm 8',
30685
31060
  'nth:lcm(100, 25)',
30686
31061
  'nth:lcm(37, 1)',
30687
- 'nth:lcm(0, 0)',
30688
31062
  'nth:lcm(0, 5)',
30689
31063
  'nth:lcm(5, 0)',
30690
31064
  ],