hclang 0.23.2 → 0.24.1
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/esm/lib/bundle/hc-sources.js +132 -62
- package/esm/lib/frames/frame-symbol.js +4 -2
- package/esm/lib/ops/iterators.js +11 -0
- package/esm/lib/ops.js +2 -1
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -468,6 +468,35 @@ export const HC_SOURCES = new Map([
|
|
|
468
468
|
"; [([1, 2] & r) = m, r]",
|
|
469
469
|
"# [<>, [0]]",
|
|
470
470
|
"```",
|
|
471
|
+
"## A splice joins the answers",
|
|
472
|
+
"",
|
|
473
|
+
"**Decision.** `&|` is the third thing that can become of each answer (#421).",
|
|
474
|
+
"It applies each element as `&` does, to a fresh copy of the receiver, and",
|
|
475
|
+
"splices the answers into one fresh array: each answer contributes its elements,",
|
|
476
|
+
"in order and shared. Anything which is not an aggregate is its own single",
|
|
477
|
+
"element, and nil contributes nothing. So concatenation is a splice of the",
|
|
478
|
+
"aggregates themselves, and filtering is a splice of a conditional",
|
|
479
|
+
"```",
|
|
480
|
+
"; [[1], [2, 3], []] &| {_}",
|
|
481
|
+
"# [1, 2, 3]",
|
|
482
|
+
"; [1, 2, 3, 4] &| {(_ = 2) ? {__}}",
|
|
483
|
+
"# [2]",
|
|
484
|
+
"; [1, 2] &| {[_, _]}",
|
|
485
|
+
"# [1, 1, 2, 2]",
|
|
486
|
+
"; [1, 2] &| [0]",
|
|
487
|
+
"# [0, 1, 0, 2]",
|
|
488
|
+
"; .inner [9];",
|
|
489
|
+
"; [(([inner] &| {[_]}) .0) === inner, [] &| {_}]",
|
|
490
|
+
"# [<>, []]",
|
|
491
|
+
"```",
|
|
492
|
+
"A splice is native and linear, where a reduce into an accumulator that streams",
|
|
493
|
+
"each answer in would copy what it has so far at every step. Repetition is the",
|
|
494
|
+
"special case of one aggregate spliced n times: `3 [1, 2]` is",
|
|
495
|
+
"`[0, 1, 2] &| {[1, 2]}`",
|
|
496
|
+
"```",
|
|
497
|
+
"; (3 [1, 2]) = ([0, 1, 2] &| {[1, 2]})",
|
|
498
|
+
"# <>",
|
|
499
|
+
"```",
|
|
471
500
|
"## A name applies like the value it names",
|
|
472
501
|
"",
|
|
473
502
|
"**Decision.** Naming a receiver does not change what applying it answers, so a",
|
|
@@ -1141,26 +1170,26 @@ export const HC_SOURCES = new Map([
|
|
|
1141
1170
|
"never affects `=`. Every observer answers a Figure, never a number or a",
|
|
1142
1171
|
"Boolean: `A`, with no children, means no, and `B` means yes. So every answer can",
|
|
1143
1172
|
"be a child, a receiver, or an argument, and the class is closed under its own",
|
|
1144
|
-
"methods. Only Cells, Form and Text leave the class, on purpose: Cells
|
|
1145
|
-
"
|
|
1146
|
-
"than computing with it.
|
|
1147
|
-
"
|
|
1173
|
+
"methods. Only Cells, Form and Text leave the class, on purpose: Cells answers",
|
|
1174
|
+
"a plain array of Figures, Form a bracket tree, and Text spells one, for reading",
|
|
1175
|
+
"a Figure rather than computing with it.",
|
|
1176
|
+
"",
|
|
1177
|
+
"Three observers share one form: a stream, a mark for each thing in it, and one",
|
|
1178
|
+
"construction. Manyness marks each child, Size marks each cell, and",
|
|
1179
|
+
"Multiplication puts y at each cell. No observer counts. A number appears only",
|
|
1180
|
+
"when a tally is read as one: its children are an aggregate, so",
|
|
1181
|
+
"`(x.size()).children.#` is the FrameCount it spells, as `(x.cells()).#` is, and",
|
|
1148
1182
|
"`x.children.#` counts x's children. A Figure's own `.#` and `.##` are `0`,",
|
|
1149
1183
|
"because its children are a property rather than its elements (#407, #411).",
|
|
1184
|
+
"Before v0.24.0 Size, Multiplication and Tally multiplication counted cells",
|
|
1185
|
+
"natively and built from the count (#414), and before v0.22.0 Size joined its",
|
|
1186
|
+
"children's Sizes one unit at a time through a helper (#415).",
|
|
1150
1187
|
"",
|
|
1151
|
-
"
|
|
1152
|
-
"
|
|
1153
|
-
"`Figure
|
|
1154
|
-
"
|
|
1155
|
-
"
|
|
1156
|
-
"children's Sizes one unit at a time, so tallies added by joining. Tallies still",
|
|
1157
|
-
"are the natural numbers in unary, they still join, `ys | x`, and two of them",
|
|
1158
|
-
"add as the Size of a Figure holding both, `(Figure [x, y]).size()`. Size now",
|
|
1159
|
-
"trades the joining derivation for construction from a native count.",
|
|
1160
|
-
"Repetition holds at most 1,000,000 elements, so Size, Multiplication and Tally",
|
|
1161
|
-
"multiplication answer `$!.repetition-size 1000000` once their count passes",
|
|
1162
|
-
"that. The joining Size had no such ceiling, but its time grew quadratically",
|
|
1163
|
-
"with the cells.",
|
|
1188
|
+
"Three Figures play the roles of zero and one, and keeping them apart is what",
|
|
1189
|
+
"the guards below are for. `Z` is zero. `U` is the unit cell that Size counts.",
|
|
1190
|
+
"`Figure [U]` is the tally one, the Size of `U`. `U` is itself `Figure [Z]`,",
|
|
1191
|
+
"one row of nothing, so wrapping zero in one Figure makes a cell: construction",
|
|
1192
|
+
"of two or more Figures adds, and construction of one wraps (#415).",
|
|
1164
1193
|
"",
|
|
1165
1194
|
"A method names its own Figure `_^`, because a bare name is looked up on the",
|
|
1166
1195
|
"argument first (spec 7), and the argument is usually another Figure. For the",
|
|
@@ -1187,44 +1216,39 @@ export const HC_SOURCES = new Map([
|
|
|
1187
1216
|
"```;",
|
|
1188
1217
|
" .many {Figure (_^.children & {B})};",
|
|
1189
1218
|
"```",
|
|
1190
|
-
"**Size**, `x.size()`: a tally with one unit cell `U` per cell
|
|
1191
|
-
"
|
|
1192
|
-
"
|
|
1193
|
-
"count and forgets shape, nesting, order, reuse and identity",
|
|
1219
|
+
"**Size**, `x.size()`: a tally with one unit cell `U` per cell, as Manyness has",
|
|
1220
|
+
"one mark per child. It keeps the cell count and forgets shape, nesting, order,",
|
|
1221
|
+
"reuse and identity",
|
|
1194
1222
|
"```;",
|
|
1195
|
-
" .size {
|
|
1196
|
-
"```",
|
|
1197
|
-
"**Cells**, `x.cells()`: the
|
|
1198
|
-
"
|
|
1199
|
-
"
|
|
1200
|
-
"
|
|
1201
|
-
"
|
|
1223
|
+
" .size {Figure (_^.cells() & {U})};",
|
|
1224
|
+
"```",
|
|
1225
|
+
"**Cells**, `x.cells()`: the cells of x, in order, each one itself. Any Figure",
|
|
1226
|
+
"shaped like `U` is a cell, and every other Figure's cells are its children's,",
|
|
1227
|
+
"spliced into one array by `&|` (#421). The unit case comes first, because a",
|
|
1228
|
+
"unit's only child is `Z`. It keeps the cells and their order, and forgets where",
|
|
1229
|
+
"they were. A block in a method counts carets lexically, so the cell itself is",
|
|
1230
|
+
"`_^^` inside the branch",
|
|
1202
1231
|
"```;",
|
|
1203
1232
|
" .cells {.kids _^.children;",
|
|
1204
|
-
" (kids = U.children) ? {
|
|
1233
|
+
" (kids = U.children) ? {[_^^]} : {kids &| {_.cells()}}};",
|
|
1205
1234
|
"```",
|
|
1206
|
-
"**Multiplication**, `x.mul y`: y
|
|
1207
|
-
"
|
|
1208
|
-
"
|
|
1235
|
+
"**Multiplication**, `x.mul y`: y at every cell of x, and `Z` when y is `Z`. It",
|
|
1236
|
+
"keeps y's identity in every position, and it forgets x's shape. Without the",
|
|
1237
|
+
"guard, a one-cell x would answer `Figure [Z]`, which is a cell rather than zero",
|
|
1209
1238
|
"```;",
|
|
1210
|
-
" .mul {.y _; .
|
|
1239
|
+
" .mul {.y _; .cells _^.cells(); (y = Z) ? {Z} : {Figure (cells & {y})}};",
|
|
1211
1240
|
"```",
|
|
1212
1241
|
"**Tally multiplication**, `x.size_mul y`: the Size of a Figure holding y once",
|
|
1213
|
-
"per child of x
|
|
1214
|
-
"
|
|
1215
|
-
"included. Building the Figure would go wrong there, as Multiplication would",
|
|
1216
|
-
"without its guard: one row of nothing, `Figure [Z]`, has the form of `U` and",
|
|
1217
|
-
"would count as a cell. It keeps the cell count and forgets both shapes",
|
|
1242
|
+
"per child of x, and `Z` when y is `Z`, for the reason Multiplication guards. It",
|
|
1243
|
+
"keeps the cell count and forgets both shapes",
|
|
1218
1244
|
"```;",
|
|
1219
|
-
" .size_mul {.
|
|
1220
|
-
" (
|
|
1245
|
+
" .size_mul {.y _; .kids _^.children;",
|
|
1246
|
+
" (y = Z) ? {Z} : {(Figure (kids & {y})).size()}};",
|
|
1221
1247
|
"```",
|
|
1222
|
-
"**Size-equivalence**, `x.size_equivalent y`: `U` when the two Sizes
|
|
1223
|
-
"`Z` otherwise. It
|
|
1224
|
-
"agree exactly when the two tallies do, so it joins no tally. It keeps only",
|
|
1225
|
-
"whether the cell counts agree",
|
|
1248
|
+
"**Size-equivalence**, `x.size_equivalent y`: `U` when the two Sizes are the",
|
|
1249
|
+
"same tally and `Z` otherwise. It keeps only whether the cell counts agree",
|
|
1226
1250
|
"```;",
|
|
1227
|
-
" .size_equivalent {((
|
|
1251
|
+
" .size_equivalent {((_^.size()) = (_.size())) ? {U} : {Z}};",
|
|
1228
1252
|
"```",
|
|
1229
1253
|
"**Sameness of form**, `x.sameform y`: `B` when `x = y`. It compares child by",
|
|
1230
1254
|
"child and forgets identity and reuse",
|
|
@@ -1306,8 +1330,21 @@ export const HC_SOURCES = new Map([
|
|
|
1306
1330
|
"; [(3 U) = ((U U) U), ((3 U).children .0) === Z, ((3 U).children .2) === U, U = (Figure [Z])]",
|
|
1307
1331
|
"# [<>, <>, <>, <>]",
|
|
1308
1332
|
"```",
|
|
1333
|
+
"So `n U` is not the tally n. Repetition starts from nil, so its first step",
|
|
1334
|
+
"answers U itself, whose child is `Z`, and `3 U` holds `Z` and two units. A tally",
|
|
1335
|
+
"starts from zero instead: join n units onto `Z`, or construct them. Repetition",
|
|
1336
|
+
"keeps nil as its start, because a declared zero would be a new protocol point",
|
|
1337
|
+
"with this one use (#415)",
|
|
1338
|
+
"```",
|
|
1339
|
+
"; [((3 U).size()).children.#, (((3 [U]) | Z).size()).children.#, ((3 [U]) | Z) = (Figure (3 [U]))]",
|
|
1340
|
+
"# [2, 3, <>]",
|
|
1341
|
+
"```",
|
|
1309
1342
|
"A join copies its receiver once and appends in place after that, so it is",
|
|
1310
|
-
"quick, and the receiver and every child keep their identity",
|
|
1343
|
+
"quick, and the receiver and every child keep their identity. Each step still",
|
|
1344
|
+
"copies the children it has so far, because a collect through a name always lands",
|
|
1345
|
+
"on a fresh array (#386). That keeps a join quadratic in pointer copies, about",
|
|
1346
|
+
"0.9 s for 4,096 units, and the observers never join: they construct from a",
|
|
1347
|
+
"stream in one step (#415)",
|
|
1311
1348
|
"```",
|
|
1312
1349
|
"; .joined ((512 [U]) | Z);",
|
|
1313
1350
|
"; [joined.children.#, Z = (Figure []), (joined.children .511) === U]",
|
|
@@ -1323,8 +1360,8 @@ export const HC_SOURCES = new Map([
|
|
|
1323
1360
|
"# [<>, <>, <>, ()]",
|
|
1324
1361
|
"```",
|
|
1325
1362
|
"Size is recursive cell volume. `Z` is `A` and `U` is `B`, the same mark",
|
|
1326
|
-
"Manyness uses, so a count is itself a Figure of units. Size
|
|
1327
|
-
"
|
|
1363
|
+
"Manyness uses, so a count is itself a Figure of units. Size marks each of the",
|
|
1364
|
+
"cells Cells finds, as Manyness marks each child. Cells tests form, so any Figure",
|
|
1328
1365
|
"shaped like `U` is a cell",
|
|
1329
1366
|
"```",
|
|
1330
1367
|
"; [Z === A, U === B]",
|
|
@@ -1347,18 +1384,20 @@ export const HC_SOURCES = new Map([
|
|
|
1347
1384
|
"; [((Figure [row2, row3]).size()) = (row3.children | row2), ((Figure [Z, Z]).size()) = Z, ((Figure [Z]).size()) = (Figure [U])]",
|
|
1348
1385
|
"# [<>, <>, <>]",
|
|
1349
1386
|
"```",
|
|
1350
|
-
"Size
|
|
1351
|
-
"`
|
|
1387
|
+
"Size constructs its answer, so a Figure with no cells has a Size equal to `Z`",
|
|
1388
|
+
"in form but not `Z` itself: having no cells and being zero are different facts,",
|
|
1389
|
+
"and Size promises the first. Every unit of a Size is `U` itself",
|
|
1352
1390
|
"```",
|
|
1353
|
-
"; [(Z.size()) === Z, ((Figure [Z, Z]).size())
|
|
1354
|
-
"# [<>, <>, <>]",
|
|
1391
|
+
"; [(Z.size()) = Z, (Z.size()) === Z, ((Figure [Z, Z]).size()) = Z, ((U.size()).children .0) === U]",
|
|
1392
|
+
"# [<>, (), <>, <>]",
|
|
1355
1393
|
"```",
|
|
1356
1394
|
"A tally is its own Size, so Size is idempotent",
|
|
1357
1395
|
"```",
|
|
1358
1396
|
"; ((two_fours.size()).size()) = (two_fours.size())",
|
|
1359
1397
|
"# <>",
|
|
1360
1398
|
"```",
|
|
1361
|
-
"
|
|
1399
|
+
"Construction from a stream is linear, so a large Size is quick: 256 cells,",
|
|
1400
|
+
"built by Multiplication",
|
|
1362
1401
|
"```",
|
|
1363
1402
|
"; .row16 (row4.mul row4); .row256 (row16.mul row16);",
|
|
1364
1403
|
"; [(row256.size()).children.#, ((row256.size()).children .255) === U]",
|
|
@@ -1371,12 +1410,12 @@ export const HC_SOURCES = new Map([
|
|
|
1371
1410
|
"; [E.children.#, (E.many()).children.#, (two_fours.size()).children.#, E.#, E.##, E.children.##] = [2, 2, 8, 0, 0, 0]",
|
|
1372
1411
|
"# <>",
|
|
1373
1412
|
"```",
|
|
1374
|
-
"Cells
|
|
1375
|
-
"
|
|
1413
|
+
"Cells answers the cells themselves, in order, wherever they were nested, and",
|
|
1414
|
+
"`.#` reads how many there are, as it reads a tally",
|
|
1376
1415
|
"```",
|
|
1377
|
-
"; [(E.cells()) = [
|
|
1378
|
-
"# [<>, <>, <>, <>]",
|
|
1379
|
-
"; [(two_fours.cells())
|
|
1416
|
+
"; [(E.cells()) = [B], ((E.cells()) .0) === B, (deep4.cells()) = row4.children, (Z.cells()) = [], ((U.cells()) .0) === U]",
|
|
1417
|
+
"# [<>, <>, <>, <>, <>]",
|
|
1418
|
+
"; [(two_fours.cells()).#, (deep4.cells()).#, (two_fours.size()).children.#] = [8, 4, 8]",
|
|
1380
1419
|
"# <>",
|
|
1381
1420
|
"```",
|
|
1382
1421
|
"## The semiring",
|
|
@@ -1392,6 +1431,21 @@ export const HC_SOURCES = new Map([
|
|
|
1392
1431
|
"; [(U.mul Z) = Z, ((Figure [Z]).size()) = (Figure [U])]",
|
|
1393
1432
|
"# [<>, <>]",
|
|
1394
1433
|
"```",
|
|
1434
|
+
"That exception is the price of a unit defined by form, and the module pays it",
|
|
1435
|
+
"on purpose (#415). Construction of two or more Figures adds, and construction",
|
|
1436
|
+
"of one wraps: wrapping keeps the Size of anything that is not shaped like zero,",
|
|
1437
|
+
"and wrapping zero makes a cell. Counting cells by identity instead, as `_^ === U`,",
|
|
1438
|
+
"would remove both guards, but a separately built `Figure [Figure []]`, equal to",
|
|
1439
|
+
"`U` in every child, would then have no cells, so Size would no longer be a",
|
|
1440
|
+
"function of form. Tried against the 55 claims this file held at v0.24.0,",
|
|
1441
|
+
"identity cells failed only the three that say a form-equal unit is a cell",
|
|
1442
|
+
"```",
|
|
1443
|
+
"; [(Figure [row2]).size_equivalent row2, (Figure [Z]).size_equivalent U, (Figure [Z]).size_equivalent Z] = [U, U, Z]",
|
|
1444
|
+
"# <>",
|
|
1445
|
+
"; .U2 (Figure [Figure []]);",
|
|
1446
|
+
"; [U2 = U, U2 === U, (U2.size()) = (U.size())]",
|
|
1447
|
+
"# [<>, (), <>]",
|
|
1448
|
+
"```",
|
|
1395
1449
|
"A non-square product is two occurrences of one three-cell row, and both",
|
|
1396
1450
|
"positions are the same `row3`. Manyness sees two rows, while Size counts six",
|
|
1397
1451
|
"```",
|
|
@@ -1402,7 +1456,9 @@ export const HC_SOURCES = new Map([
|
|
|
1402
1456
|
"# [<>, <>]",
|
|
1403
1457
|
"```",
|
|
1404
1458
|
"Size takes construction to joining and multiplication to `size_mul`, so both",
|
|
1405
|
-
"recipes respect `≈`; the checks also use differently nested, equal-Size inputs",
|
|
1459
|
+
"recipes respect `≈`; the checks also use differently nested, equal-Size inputs.",
|
|
1460
|
+
"Size, `size_mul` and `size_equivalent` all construct, and none counts, so every",
|
|
1461
|
+
"check here and below compares two constructions (#415)",
|
|
1406
1462
|
"```",
|
|
1407
1463
|
"; [((Figure [row2, row3]).size()) = (Figure [U, U, U, U, U]), (rectangle23.size()) = ((row2.size()).size_mul (row3.size()))]",
|
|
1408
1464
|
"# [<>, <>]",
|
|
@@ -1427,10 +1483,12 @@ export const HC_SOURCES = new Map([
|
|
|
1427
1483
|
"# <>",
|
|
1428
1484
|
"```",
|
|
1429
1485
|
"Read as natural numbers, Size takes construction to `+` and multiplication to",
|
|
1430
|
-
"`*`, so the same laws hold of FrameCount arithmetic, where they are native",
|
|
1486
|
+
"`*`, so the same laws hold of FrameCount arithmetic, where they are native.",
|
|
1487
|
+
"Each side reads a tally that was constructed, so the reading checks the",
|
|
1488
|
+
"construction rather than replacing it",
|
|
1431
1489
|
"```",
|
|
1432
|
-
"; [((Figure [row2, row3]).
|
|
1433
|
-
"# [<>, <>]",
|
|
1490
|
+
"; [((Figure [row2, row3]).size()).children.# = (((row2.size()).children.#) + ((row3.size()).children.#)), (rectangle23.size()).children.# = (((row2.size()).children.#) * ((row3.size()).children.#)), (rectangle23.size()).children.# = 6]",
|
|
1491
|
+
"# [<>, <>, <>]",
|
|
1434
1492
|
"; [(Figure [Figure [row2, row3], row4]).size_equivalent (Figure [row2, Figure [row3, row4]]), (Figure [row2, row3]).size_equivalent (Figure [row3, row2])] = [U, U]",
|
|
1435
1493
|
"# <>",
|
|
1436
1494
|
"; (((row2.mul row3).mul row4).size_equivalent (row2.mul (row3.mul row4))) = U",
|
|
@@ -3350,6 +3408,18 @@ export const HC_SOURCES = new Map([
|
|
|
3350
3408
|
"; mag []",
|
|
3351
3409
|
"# 25",
|
|
3352
3410
|
"```",
|
|
3411
|
+
"A closure keeps the scope it was created in wherever it is later read, so one",
|
|
3412
|
+
"closure handed to another as an argument still finds its own names (#424). A",
|
|
3413
|
+
"closure factory therefore nests exactly as often as it is called",
|
|
3414
|
+
"```",
|
|
3415
|
+
"; .Mk {.lower _; {[“level”, lower _]}};",
|
|
3416
|
+
"; .L0 {“base”};",
|
|
3417
|
+
"; (Mk (Mk L0)) 7",
|
|
3418
|
+
"# [“level”, [“level”, “base”]]",
|
|
3419
|
+
"; .Ret {.lower _; {lower}};",
|
|
3420
|
+
"; ((Ret (Ret L0)) 0) 0",
|
|
3421
|
+
"# { “base” }",
|
|
3422
|
+
"```",
|
|
3353
3423
|
"Implicit arguments are a code smell, and will generate a warning.",
|
|
3354
3424
|
"However, they can be very useful when debugging or refactoring. That may seem",
|
|
3355
3425
|
"dangerous, but the data protection rules (below) largely limit what the called",
|
|
@@ -106,7 +106,9 @@ export class FrameSymbol extends FrameAtom {
|
|
|
106
106
|
// Every successful read gets its own lexical projection. Closures bind
|
|
107
107
|
// a scoped copy, aggregates keep their exact identity behind a handle,
|
|
108
108
|
// and immutable values use a plumbing copy. The shared binding is never
|
|
109
|
-
// re-parented for the benefit of one reader
|
|
109
|
+
// re-parented for the benefit of one reader, so only a projection this
|
|
110
|
+
// read created takes the read site as its `up`: a closure that is
|
|
111
|
+
// already bound answers itself and keeps the scope it was made in.
|
|
110
112
|
const isCanonicalBoolean = value === Frame.nil || value === Frame.all;
|
|
111
113
|
const continuation = context instanceof FrameHandle
|
|
112
114
|
? context
|
|
@@ -116,7 +118,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
116
118
|
: value instanceof FrameArray || isCanonicalBoolean
|
|
117
119
|
? value
|
|
118
120
|
: value.copy();
|
|
119
|
-
if (
|
|
121
|
+
if (resolved !== value) {
|
|
120
122
|
resolved.up = continuation;
|
|
121
123
|
}
|
|
122
124
|
// Built-in control flow receives the exact active capability only for
|
package/esm/lib/ops/iterators.js
CHANGED
|
@@ -40,6 +40,17 @@ const members = (source) => {
|
|
|
40
40
|
* otherwise collect every element and be answered each time.
|
|
41
41
|
*/
|
|
42
42
|
export const MapElements = (source, receiver, receiverState) => new FrameArray(source.elements().map((value) => receiver.collectingCopy().call(value, Frame.nil, receiverState)));
|
|
43
|
+
/**
|
|
44
|
+
* `&|` applies each element on its own, as `&` does, and splices the answers
|
|
45
|
+
* into one fresh array: each answer contributes its elements, in order and
|
|
46
|
+
* shared, and a nil answer contributes nothing (#421). Anything which is not
|
|
47
|
+
* an aggregate is its own single element, so `xs &| {_}` concatenates the
|
|
48
|
+
* aggregates xs holds, and a block that answers nil for some elements filters.
|
|
49
|
+
*/
|
|
50
|
+
export const SpliceElements = (source, receiver, receiverState) => new FrameArray(source.elements().flatMap((value) => {
|
|
51
|
+
const answer = receiver.collectingCopy().call(value, Frame.nil, receiverState);
|
|
52
|
+
return answer.is.void ? [] : answer.elements();
|
|
53
|
+
}));
|
|
43
54
|
/** `|` threads each element through the receiver the last step answered. */
|
|
44
55
|
export const ReduceElements = (source, receiver, receiverState) => source.reduce(receiver, receiverState);
|
|
45
56
|
/** `&&` maps the same stream widened to `[key, value]` tuples, as `&` does. */
|
package/esm/lib/ops.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { IfElse, IfThen } from "./ops/conditionals.js";
|
|
2
2
|
import { FrameOps } from "./ops/frame-ops.js";
|
|
3
|
-
import { MapElements, MapMembers, ReduceElements, ReduceMembers, } from "./ops/iterators.js";
|
|
3
|
+
import { MapElements, MapMembers, ReduceElements, ReduceMembers, SpliceElements, } from "./ops/iterators.js";
|
|
4
4
|
import { Add, Divide, Equals, GreaterThan, GreaterThanOrEqual, Identical, LessThan, LessThanOrEqual, Modulo, Multiply, Power, Subtract, TypeEquals, } from "./ops/math.js";
|
|
5
5
|
import { BindType, HasType } from "./ops/type-operations.js";
|
|
6
6
|
export { FrameCurry } from "./ops/frame-curry.js";
|
|
7
7
|
export const Ops = new FrameOps({
|
|
8
8
|
"&": MapElements,
|
|
9
9
|
"&&": MapMembers,
|
|
10
|
+
"&|": SpliceElements,
|
|
10
11
|
":": IfElse,
|
|
11
12
|
"?": IfThen,
|
|
12
13
|
"|": ReduceElements,
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.24.1";
|