squint-cljs 0.5.86 → 0.6.87
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/README.md +2 -0
- package/lib/cli.js +37 -37
- package/lib/cljs.pprint.js +114 -114
- package/lib/compiler.js +270 -271
- package/lib/compiler.node.js +25 -25
- package/lib/compiler.sci.js +1012 -1012
- package/lib/node.nrepl_server.js +14 -14
- package/lib/squint.core.umd.js +1 -1
- package/package.json +1 -1
- package/src/squint/core.js +354 -42
package/src/squint/core.js
CHANGED
|
@@ -26,7 +26,7 @@ function walkArray(arr, comp) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function _EQ_(...xs) {
|
|
29
|
-
return walkArray(xs, (x,y) => x === y);
|
|
29
|
+
return walkArray(xs, (x, y) => x === y);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function _GT_(...xs) {
|
|
@@ -605,7 +605,7 @@ export function reduced_QMARK_(x) {
|
|
|
605
605
|
export function reduce(f, arg1, arg2) {
|
|
606
606
|
f = toFn(f);
|
|
607
607
|
let coll, val;
|
|
608
|
-
if (
|
|
608
|
+
if (arguments.length === 2) {
|
|
609
609
|
// (reduce f coll)
|
|
610
610
|
const iter = iterable(arg1)[Symbol.iterator]();
|
|
611
611
|
const vd = iter.next();
|
|
@@ -659,7 +659,7 @@ function* _reductions3(f, init, coll) {
|
|
|
659
659
|
|
|
660
660
|
export function reductions(f, arg1, arg2) {
|
|
661
661
|
f = toFn(f);
|
|
662
|
-
if (
|
|
662
|
+
if (arguments.length === 2) {
|
|
663
663
|
return lazy(function* () {
|
|
664
664
|
yield* _reductions2(f, iterable(arg1)[Symbol.iterator]());
|
|
665
665
|
});
|
|
@@ -785,7 +785,7 @@ function filter1(pred) {
|
|
|
785
785
|
}
|
|
786
786
|
|
|
787
787
|
export function filter(pred, coll) {
|
|
788
|
-
if (
|
|
788
|
+
if (arguments.length === 1) {
|
|
789
789
|
return filter1(pred);
|
|
790
790
|
}
|
|
791
791
|
pred = toFn(pred);
|
|
@@ -806,8 +806,24 @@ export function remove(pred, coll) {
|
|
|
806
806
|
return filter(complement(pred), coll);
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
+
function map_indexed1(f) {
|
|
810
|
+
return (rf) => {
|
|
811
|
+
let i = -1;
|
|
812
|
+
return (...args) => {
|
|
813
|
+
switch (args.length) {
|
|
814
|
+
case 0: return rf();
|
|
815
|
+
case 1: return rf(args[0]);
|
|
816
|
+
case 2: return rf(args[0], f((i = i + 1, i), args[1]));
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
|
|
809
822
|
export function map_indexed(f, coll) {
|
|
810
823
|
f = toFn(f);
|
|
824
|
+
if (arguments.length === 1) {
|
|
825
|
+
return map_indexed1(f);
|
|
826
|
+
}
|
|
811
827
|
const ret = [];
|
|
812
828
|
let i = 0;
|
|
813
829
|
for (const x of iterable(coll)) {
|
|
@@ -834,25 +850,30 @@ function keep_indexed2(f, coll) {
|
|
|
834
850
|
function keep_indexed1(f) {
|
|
835
851
|
return (rf) => {
|
|
836
852
|
let ia = -1;
|
|
837
|
-
return (
|
|
838
|
-
|
|
853
|
+
return (...args) => {
|
|
854
|
+
const al = args.length;
|
|
855
|
+
if (al === 0) {
|
|
839
856
|
return rf();
|
|
840
857
|
}
|
|
841
|
-
if (
|
|
842
|
-
return rf(
|
|
858
|
+
if (al === 1) {
|
|
859
|
+
return rf(args[0]);
|
|
843
860
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
861
|
+
if (al === 2) {
|
|
862
|
+
const result = args[0];
|
|
863
|
+
const input = args[1];
|
|
864
|
+
ia++;
|
|
865
|
+
const v = f(ia, input);
|
|
866
|
+
if (v == null) {
|
|
867
|
+
return result;
|
|
868
|
+
}
|
|
869
|
+
return rf(result, v);
|
|
848
870
|
}
|
|
849
|
-
return rf(result, v);
|
|
850
871
|
};
|
|
851
872
|
};
|
|
852
873
|
}
|
|
853
874
|
|
|
854
875
|
export function keep_indexed(f, coll) {
|
|
855
|
-
if (
|
|
876
|
+
if (arguments.length === 1) {
|
|
856
877
|
return keep_indexed1(f);
|
|
857
878
|
} else {
|
|
858
879
|
return keep_indexed2(f, coll);
|
|
@@ -900,30 +921,32 @@ export function prn(...xs) {
|
|
|
900
921
|
println(pr_str(...xs));
|
|
901
922
|
}
|
|
902
923
|
|
|
903
|
-
export
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
924
|
+
export class Atom {
|
|
925
|
+
constructor(init) {
|
|
926
|
+
this.val = init;
|
|
927
|
+
this._watches = {};
|
|
928
|
+
this._deref = () => this.val;
|
|
929
|
+
this._hasWatches = false;
|
|
930
|
+
this._reset_BANG_ = (x) => {
|
|
931
|
+
const old_val = this.val;
|
|
932
|
+
this.val = x;
|
|
933
|
+
if (this._hasWatches) {
|
|
934
|
+
for (const entry of Object.entries(this._watches)) {
|
|
935
|
+
const k = entry[0];
|
|
936
|
+
const f = entry[1];
|
|
937
|
+
f(k, this, old_val, x);
|
|
938
|
+
}
|
|
916
939
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
940
|
+
return x;
|
|
941
|
+
};
|
|
942
|
+
this._add_watch = (k, fn) => {
|
|
943
|
+
this._watches[k] = fn;
|
|
944
|
+
this._hasWatches = true;
|
|
945
|
+
};
|
|
946
|
+
this._remove_watch = (k) => {
|
|
947
|
+
delete this._watches[k];
|
|
948
|
+
};
|
|
949
|
+
}
|
|
927
950
|
}
|
|
928
951
|
|
|
929
952
|
export function atom(init) {
|
|
@@ -1126,7 +1149,33 @@ export function interleave(...colls) {
|
|
|
1126
1149
|
});
|
|
1127
1150
|
}
|
|
1128
1151
|
|
|
1152
|
+
function interpose1(sep) {
|
|
1153
|
+
return (rf) => {
|
|
1154
|
+
let started = false;
|
|
1155
|
+
return (...args) => {
|
|
1156
|
+
switch (args.length) {
|
|
1157
|
+
case 0: return rf();
|
|
1158
|
+
case 1: return rf(args[0]);
|
|
1159
|
+
case 2: {
|
|
1160
|
+
if (started) {
|
|
1161
|
+
const sepr = rf(args[0], sep);
|
|
1162
|
+
if (reduced_QMARK_(sepr)) {
|
|
1163
|
+
return sepr;
|
|
1164
|
+
} else {
|
|
1165
|
+
return rf(sepr, args[1]);
|
|
1166
|
+
}
|
|
1167
|
+
} else {
|
|
1168
|
+
started = true;
|
|
1169
|
+
return rf(args[0], args[1]);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1129
1177
|
export function interpose(sep, coll) {
|
|
1178
|
+
if (arguments.length === 1) return interpose1(sep);
|
|
1130
1179
|
return drop(1, interleave(repeat(sep), coll));
|
|
1131
1180
|
}
|
|
1132
1181
|
|
|
@@ -1143,7 +1192,50 @@ export function select_keys(o, ks) {
|
|
|
1143
1192
|
return ret;
|
|
1144
1193
|
}
|
|
1145
1194
|
|
|
1195
|
+
export function unreduced(x) {
|
|
1196
|
+
if (reduced_QMARK_(x)) {
|
|
1197
|
+
return deref(x);
|
|
1198
|
+
} else {
|
|
1199
|
+
return x;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
function partition_all1(n) {
|
|
1204
|
+
return (rf) => {
|
|
1205
|
+
let a = [];
|
|
1206
|
+
return (...args) => {
|
|
1207
|
+
let result, v;
|
|
1208
|
+
switch (args.length) {
|
|
1209
|
+
case 0: return rf();
|
|
1210
|
+
case 1: {
|
|
1211
|
+
result = args[0];
|
|
1212
|
+
if (a.length !== 0) {
|
|
1213
|
+
v = [...a];
|
|
1214
|
+
a = [];
|
|
1215
|
+
result = unreduced(rf(result, v));
|
|
1216
|
+
}
|
|
1217
|
+
return rf(result);
|
|
1218
|
+
}
|
|
1219
|
+
case 2: {
|
|
1220
|
+
result = args[0];
|
|
1221
|
+
a.push(args[1]);
|
|
1222
|
+
if (n === a.length) {
|
|
1223
|
+
v = [...a];
|
|
1224
|
+
a = [];
|
|
1225
|
+
return rf(result, v);
|
|
1226
|
+
} else {
|
|
1227
|
+
return result;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1146
1235
|
export function partition_all(n, ...args) {
|
|
1236
|
+
if (arguments.length === 1) {
|
|
1237
|
+
return partition_all1(n);
|
|
1238
|
+
}
|
|
1147
1239
|
let step = n,
|
|
1148
1240
|
coll = args[0];
|
|
1149
1241
|
|
|
@@ -1195,8 +1287,54 @@ function partitionInternal(n, step, pad, coll, all) {
|
|
|
1195
1287
|
});
|
|
1196
1288
|
}
|
|
1197
1289
|
|
|
1290
|
+
function partition_by1(f) {
|
|
1291
|
+
return (rf) => {
|
|
1292
|
+
let a = [];
|
|
1293
|
+
const none = {};
|
|
1294
|
+
let pa = none;
|
|
1295
|
+
return (...args) => {
|
|
1296
|
+
const l = args.length;
|
|
1297
|
+
let v;
|
|
1298
|
+
if (l === 0) {
|
|
1299
|
+
return rf();
|
|
1300
|
+
}
|
|
1301
|
+
if (l === 1) {
|
|
1302
|
+
let result = args[0];
|
|
1303
|
+
if (a.length !== 0) {
|
|
1304
|
+
const v = [...a];
|
|
1305
|
+
a = [];
|
|
1306
|
+
result = unreduced(rf(result, v));
|
|
1307
|
+
}
|
|
1308
|
+
return rf(result);
|
|
1309
|
+
}
|
|
1310
|
+
if (l === 2) {
|
|
1311
|
+
const result = args[0];
|
|
1312
|
+
const input = args[1];
|
|
1313
|
+
const pval = pa;
|
|
1314
|
+
const val = f(input);
|
|
1315
|
+
pa = val;
|
|
1316
|
+
if (pval === none || val === pval) {
|
|
1317
|
+
a.push(input);
|
|
1318
|
+
return result;
|
|
1319
|
+
} else {
|
|
1320
|
+
const v = [...a];
|
|
1321
|
+
a = [];
|
|
1322
|
+
const ret = rf(result, v);
|
|
1323
|
+
if (!reduced_QMARK_(ret)) {
|
|
1324
|
+
a.push(input);
|
|
1325
|
+
}
|
|
1326
|
+
return ret;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1198
1333
|
export function partition_by(f, coll) {
|
|
1199
1334
|
f = toFn(f);
|
|
1335
|
+
if (arguments.length === 1) {
|
|
1336
|
+
return partition_by1(f);
|
|
1337
|
+
}
|
|
1200
1338
|
return lazy(function* () {
|
|
1201
1339
|
const iter = es6_iterator(coll);
|
|
1202
1340
|
const _fst = iter.next();
|
|
@@ -1339,7 +1477,49 @@ export function repeat(...args) {
|
|
|
1339
1477
|
};
|
|
1340
1478
|
}
|
|
1341
1479
|
|
|
1480
|
+
export function ensure_reduced(x) {
|
|
1481
|
+
if (reduced_QMARK_(x)) {
|
|
1482
|
+
return x;
|
|
1483
|
+
} else {
|
|
1484
|
+
return reduced(x);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
function take1(n) {
|
|
1489
|
+
return (rf) => {
|
|
1490
|
+
let na = n;
|
|
1491
|
+
return (...args) => {
|
|
1492
|
+
const al = args.length;
|
|
1493
|
+
if (al === 0) {
|
|
1494
|
+
return rf();
|
|
1495
|
+
}
|
|
1496
|
+
if (al === 1) {
|
|
1497
|
+
const result = args[0];
|
|
1498
|
+
return rf(result);
|
|
1499
|
+
}
|
|
1500
|
+
if (al === 2) {
|
|
1501
|
+
let result = args[0];
|
|
1502
|
+
const input = args[1];
|
|
1503
|
+
const n = na;
|
|
1504
|
+
const nn = (na = na - 1, na);
|
|
1505
|
+
if (n > 0) {
|
|
1506
|
+
result = rf(result, input);
|
|
1507
|
+
}
|
|
1508
|
+
if (!(nn > 0)) {
|
|
1509
|
+
return ensure_reduced(result);
|
|
1510
|
+
}
|
|
1511
|
+
else {
|
|
1512
|
+
return result;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1342
1519
|
export function take(n, coll) {
|
|
1520
|
+
if (arguments.length === 1) {
|
|
1521
|
+
return take1(n);
|
|
1522
|
+
}
|
|
1343
1523
|
return lazy(function* () {
|
|
1344
1524
|
let i = n - 1;
|
|
1345
1525
|
for (const x of iterable(coll)) {
|
|
@@ -1353,8 +1533,30 @@ export function take(n, coll) {
|
|
|
1353
1533
|
});
|
|
1354
1534
|
}
|
|
1355
1535
|
|
|
1536
|
+
function take_while1(pred) {
|
|
1537
|
+
return (rf) => {
|
|
1538
|
+
return (...args) => {
|
|
1539
|
+
const al = args.length;
|
|
1540
|
+
if (al === 0) return rf();
|
|
1541
|
+
if (al === 1) return rf(args[0]);
|
|
1542
|
+
if (al === 2) {
|
|
1543
|
+
const result = args[0];
|
|
1544
|
+
const input = args[1];
|
|
1545
|
+
if (truth_(pred(input))) {
|
|
1546
|
+
return rf(result, input);
|
|
1547
|
+
} else {
|
|
1548
|
+
return reduced(result);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1356
1555
|
export function take_while(pred, coll) {
|
|
1357
1556
|
pred = toFn(pred);
|
|
1557
|
+
if (arguments.length === 1) {
|
|
1558
|
+
return take_while1(pred);
|
|
1559
|
+
}
|
|
1358
1560
|
return lazy(function* () {
|
|
1359
1561
|
for (const o of iterable(coll)) {
|
|
1360
1562
|
if (truth_(pred(o))) yield o;
|
|
@@ -1363,7 +1565,28 @@ export function take_while(pred, coll) {
|
|
|
1363
1565
|
});
|
|
1364
1566
|
}
|
|
1365
1567
|
|
|
1568
|
+
function take_nth1(n) {
|
|
1569
|
+
return (rf) => {
|
|
1570
|
+
let ia = -1;
|
|
1571
|
+
return (...args) => {
|
|
1572
|
+
const al = args.length;
|
|
1573
|
+
if (al === 0) return rf();
|
|
1574
|
+
if (al === 1) return rf(args[0]);
|
|
1575
|
+
if (al === 2) {
|
|
1576
|
+
const result = args[0];
|
|
1577
|
+
const input = args[1];
|
|
1578
|
+
ia++;
|
|
1579
|
+
const i = ia;
|
|
1580
|
+
if (rem(i, n) === 0) {
|
|
1581
|
+
return rf(result, input);
|
|
1582
|
+
} else return result;
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1366
1588
|
export function take_nth(n, coll) {
|
|
1589
|
+
if (arguments.length === 1) return take_nth1(n);
|
|
1367
1590
|
if (n <= 0) {
|
|
1368
1591
|
return repeat(first(coll));
|
|
1369
1592
|
}
|
|
@@ -1392,7 +1615,32 @@ export function cycle(coll) {
|
|
|
1392
1615
|
});
|
|
1393
1616
|
}
|
|
1394
1617
|
|
|
1618
|
+
function drop1(n) {
|
|
1619
|
+
return (rf) => {
|
|
1620
|
+
let na = n;
|
|
1621
|
+
return (...args) => {
|
|
1622
|
+
const al = args.length;
|
|
1623
|
+
if (al === 0) {
|
|
1624
|
+
return rf();
|
|
1625
|
+
}
|
|
1626
|
+
if (al === 1) {
|
|
1627
|
+
return rf(args[0]);
|
|
1628
|
+
}
|
|
1629
|
+
if (al === 2) {
|
|
1630
|
+
const result = args[0];
|
|
1631
|
+
const input = args[1];
|
|
1632
|
+
const n = na;
|
|
1633
|
+
na--;
|
|
1634
|
+
if (n > 0) {
|
|
1635
|
+
return result;
|
|
1636
|
+
} else return rf(result, input);
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1395
1642
|
export function drop(n, xs) {
|
|
1643
|
+
if (arguments.length === 1) return drop1(n);
|
|
1396
1644
|
return lazy(function* () {
|
|
1397
1645
|
const iter = _iterator(iterable(xs));
|
|
1398
1646
|
for (let x = 0; x < n; x++) {
|
|
@@ -1402,8 +1650,35 @@ export function drop(n, xs) {
|
|
|
1402
1650
|
});
|
|
1403
1651
|
}
|
|
1404
1652
|
|
|
1653
|
+
function drop_while1(pred) {
|
|
1654
|
+
return (rf) => {
|
|
1655
|
+
let da = true;
|
|
1656
|
+
return (...args) => {
|
|
1657
|
+
const al = args.length;
|
|
1658
|
+
if (al === 0) {
|
|
1659
|
+
return rf();
|
|
1660
|
+
}
|
|
1661
|
+
if (al === 1) {
|
|
1662
|
+
return rf(args[0]);
|
|
1663
|
+
}
|
|
1664
|
+
if (al === 2) {
|
|
1665
|
+
const isDrop = da;
|
|
1666
|
+
const result = args[0];
|
|
1667
|
+
const input = args[1];
|
|
1668
|
+
if (isDrop && truth_(pred(input))) {
|
|
1669
|
+
return result;
|
|
1670
|
+
} else {
|
|
1671
|
+
da = null;
|
|
1672
|
+
return rf(result, input);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1405
1679
|
export function drop_while(pred, xs) {
|
|
1406
1680
|
pred = toFn(pred);
|
|
1681
|
+
if (arguments.length === 1) return drop_while1(pred);
|
|
1407
1682
|
return lazy(function* () {
|
|
1408
1683
|
const iter = _iterator(iterable(xs));
|
|
1409
1684
|
while (true) {
|
|
@@ -1421,7 +1696,26 @@ export function drop_while(pred, xs) {
|
|
|
1421
1696
|
});
|
|
1422
1697
|
}
|
|
1423
1698
|
|
|
1699
|
+
function distinct1() {
|
|
1700
|
+
return (rf) => {
|
|
1701
|
+
const seen = new Set();
|
|
1702
|
+
return (...args) => {
|
|
1703
|
+
const al = args.length;
|
|
1704
|
+
if (al === 0) return rf();
|
|
1705
|
+
if (al === 1) return rf(args[0]);
|
|
1706
|
+
if (al === 2) {
|
|
1707
|
+
const result = args[0];
|
|
1708
|
+
const input = args[1];
|
|
1709
|
+
if (seen.has(input)) return result;
|
|
1710
|
+
seen.add(input);
|
|
1711
|
+
return rf(result, input);
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1424
1717
|
export function distinct(coll) {
|
|
1718
|
+
if (arguments.length === 0) return distinct1();
|
|
1425
1719
|
return lazy(function* () {
|
|
1426
1720
|
const seen = new Set();
|
|
1427
1721
|
for (const x of iterable(coll)) {
|
|
@@ -1474,8 +1768,26 @@ export function not_every_QMARK_(pred, coll) {
|
|
|
1474
1768
|
return !every_QMARK_(pred, coll);
|
|
1475
1769
|
}
|
|
1476
1770
|
|
|
1771
|
+
function keep1(pred) {
|
|
1772
|
+
return (rf) => {
|
|
1773
|
+
return (...args) => {
|
|
1774
|
+
const al = args.length;
|
|
1775
|
+
if (al === 0) return rf();
|
|
1776
|
+
if (al === 1) return rf(args[0]);
|
|
1777
|
+
if (al === 2) {
|
|
1778
|
+
const result = args[0];
|
|
1779
|
+
const input = args[1];
|
|
1780
|
+
const v = pred(input);
|
|
1781
|
+
if (v == null) return result;
|
|
1782
|
+
return rf(result, v);
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1477
1788
|
export function keep(pred, coll) {
|
|
1478
1789
|
pred = toFn(pred);
|
|
1790
|
+
if (arguments.length === 1) return keep1(pred);
|
|
1479
1791
|
return lazy(function* () {
|
|
1480
1792
|
for (const o of iterable(coll)) {
|
|
1481
1793
|
const res = pred(o);
|
|
@@ -1490,7 +1802,7 @@ export function reverse(coll) {
|
|
|
1490
1802
|
}
|
|
1491
1803
|
|
|
1492
1804
|
export function sort(f, coll) {
|
|
1493
|
-
if (
|
|
1805
|
+
if (arguments.length === 1) {
|
|
1494
1806
|
coll = f;
|
|
1495
1807
|
f = undefined;
|
|
1496
1808
|
}
|
|
@@ -1522,7 +1834,7 @@ function fnToComparator(f) {
|
|
|
1522
1834
|
}
|
|
1523
1835
|
|
|
1524
1836
|
export function sort_by(keyfn, comp, coll) {
|
|
1525
|
-
if (
|
|
1837
|
+
if (arguments.length === 2) {
|
|
1526
1838
|
coll = comp;
|
|
1527
1839
|
comp = compare;
|
|
1528
1840
|
}
|
|
@@ -1588,7 +1900,7 @@ function _repeatedly(f) {
|
|
|
1588
1900
|
}
|
|
1589
1901
|
|
|
1590
1902
|
export function repeatedly(n, f) {
|
|
1591
|
-
if (
|
|
1903
|
+
if (arguments.length === 1) {
|
|
1592
1904
|
f = n;
|
|
1593
1905
|
n = undefined;
|
|
1594
1906
|
}
|
|
@@ -2364,7 +2676,7 @@ export function pop(vec) {
|
|
|
2364
2676
|
export function update_keys(m, f) {
|
|
2365
2677
|
const m2 = empty(m);
|
|
2366
2678
|
const assocFn = getAssocMut(m) || assoc_BANG_;
|
|
2367
|
-
reduce_kv(
|
|
2679
|
+
reduce_kv((acc, k, v) => {
|
|
2368
2680
|
return assocFn(acc, f(k), v);
|
|
2369
2681
|
}, m2, m);
|
|
2370
2682
|
return m2;
|
|
@@ -2373,7 +2685,7 @@ export function update_keys(m, f) {
|
|
|
2373
2685
|
export function update_vals(m, f) {
|
|
2374
2686
|
const m2 = empty(m);
|
|
2375
2687
|
const assocFn = getAssocMut(m) || assoc_BANG_;
|
|
2376
|
-
reduce_kv(
|
|
2688
|
+
reduce_kv((acc, k, v) => {
|
|
2377
2689
|
return assocFn(acc, k, f(v));
|
|
2378
2690
|
}, m2, m);
|
|
2379
2691
|
return m2;
|