functionalscript 0.0.486 → 0.0.488
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/com/cpp/module.f.cjs +1 -2
- package/com/cpp/test.f.cjs +1 -1
- package/com/cpp/testlib.f.cjs +1 -1
- package/com/rust/module.f.cjs +13 -9
- package/com/test/build.f.cjs +1 -1
- package/commonjs/build/module.f.cjs +1 -1
- package/commonjs/build/test.f.cjs +2 -1
- package/commonjs/module/module.f.cjs +1 -1
- package/commonjs/path/module.f.cjs +5 -5
- package/dev/test.mjs +1 -1
- package/doc/predefined.md +2 -2
- package/fsc/test.f.cjs +1 -1
- package/json/module.f.cjs +4 -4
- package/package.json +1 -1
- package/text/README.md +2 -2
- package/text/utf8/module.f.cjs +15 -15
- package/types/array/module.f.cjs +9 -6
- package/types/btree/find/module.f.cjs +3 -3
- package/types/btree/module.f.cjs +2 -2
- package/types/btree/remove/module.f.cjs +11 -11
- package/types/btree/remove/test.f.cjs +52 -52
- package/types/btree/set/module.f.cjs +6 -6
- package/types/btree/test.f.cjs +2 -2
- package/types/btree/types/module.f.cjs +1 -1
- package/types/byte_set/module.f.cjs +1 -1
- package/types/list/module.f.cjs +37 -38
- package/types/list/test.f.cjs +9 -9
- package/types/map/module.f.cjs +6 -6
- package/types/map/test.f.cjs +9 -9
- package/types/nullable/module.f.cjs +17 -0
- package/types/{option → nullable}/test.f.cjs +2 -2
- package/types/number/module.f.cjs +2 -2
- package/types/number/test.f.cjs +1 -1
- package/types/range_map/module.f.cjs +6 -6
- package/types/range_map/test.f.cjs +2 -2
- package/types/sorted_list/module.f.cjs +11 -12
- package/types/sorted_list/test.f.cjs +2 -2
- package/types/sorted_set/module.f.cjs +3 -3
- package/types/sorted_set/test.f.cjs +0 -1
- package/types/string_set/module.f.cjs +2 -2
- package/types/string_set/test.f.cjs +3 -3
- package/types/option/module.f.cjs +0 -17
|
@@ -8,13 +8,13 @@ const { sort } = require('../../object/module.f.cjs')
|
|
|
8
8
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
9
9
|
const set = node => value => s.set(cmp(value))(() => value)(node)
|
|
10
10
|
|
|
11
|
-
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string> |
|
|
11
|
+
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string> | null} */
|
|
12
12
|
const remove = node => value => _.nodeRemove(cmp(value))(node)
|
|
13
13
|
|
|
14
14
|
const jsonStr = json.stringify(sort)
|
|
15
15
|
|
|
16
16
|
const test = () => {
|
|
17
|
-
/** @type {btree.Node<string> |
|
|
17
|
+
/** @type {btree.Node<string> | null} */
|
|
18
18
|
let _map = ['1']
|
|
19
19
|
for (let i = 2; i <= 38; i++)
|
|
20
20
|
_map = set(_map)((i * i).toString())
|
|
@@ -32,7 +32,7 @@ const test = () => {
|
|
|
32
32
|
}
|
|
33
33
|
{
|
|
34
34
|
_map = remove(_map)("0")
|
|
35
|
-
if (_map ===
|
|
35
|
+
if (_map === null) { throw null }
|
|
36
36
|
const r = jsonStr(_map)
|
|
37
37
|
if (r !==
|
|
38
38
|
'[[[[["1"],"100",["1024"]],"1089",[["1156"],"121",["1225"]]],' +
|
|
@@ -46,7 +46,7 @@ const test = () => {
|
|
|
46
46
|
}
|
|
47
47
|
{
|
|
48
48
|
_map = remove(_map)("1")
|
|
49
|
-
if (_map ===
|
|
49
|
+
if (_map === null) { throw null }
|
|
50
50
|
const r = jsonStr(_map)
|
|
51
51
|
if (r !==
|
|
52
52
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]],' +
|
|
@@ -58,7 +58,7 @@ const test = () => {
|
|
|
58
58
|
}
|
|
59
59
|
{
|
|
60
60
|
_map = remove(_map)("4")
|
|
61
|
-
if (_map ===
|
|
61
|
+
if (_map === null) { throw null }
|
|
62
62
|
const r = jsonStr(_map)
|
|
63
63
|
if (r !==
|
|
64
64
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]],' +
|
|
@@ -70,7 +70,7 @@ const test = () => {
|
|
|
70
70
|
}
|
|
71
71
|
{
|
|
72
72
|
_map = remove(_map)("9")
|
|
73
|
-
if (_map ===
|
|
73
|
+
if (_map === null) { throw null }
|
|
74
74
|
const r = jsonStr(_map)
|
|
75
75
|
if (r !==
|
|
76
76
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]],' +
|
|
@@ -82,7 +82,7 @@ const test = () => {
|
|
|
82
82
|
}
|
|
83
83
|
{
|
|
84
84
|
_map = remove(_map)("16")
|
|
85
|
-
if (_map ===
|
|
85
|
+
if (_map === null) { throw null }
|
|
86
86
|
const r = jsonStr(_map)
|
|
87
87
|
if (r !==
|
|
88
88
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]]],' +
|
|
@@ -94,7 +94,7 @@ const test = () => {
|
|
|
94
94
|
}
|
|
95
95
|
{
|
|
96
96
|
_map = remove(_map)("25")
|
|
97
|
-
if (_map ===
|
|
97
|
+
if (_map === null) { throw null }
|
|
98
98
|
const r = jsonStr(_map)
|
|
99
99
|
if (r !==
|
|
100
100
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289","324"],"36",["361"],"400",["441","484"]]],' +
|
|
@@ -104,7 +104,7 @@ const test = () => {
|
|
|
104
104
|
}
|
|
105
105
|
{
|
|
106
106
|
_map = remove(_map)("36")
|
|
107
|
-
if (_map ===
|
|
107
|
+
if (_map === null) { throw null }
|
|
108
108
|
const r = jsonStr(_map)
|
|
109
109
|
if (r !==
|
|
110
110
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -114,7 +114,7 @@ const test = () => {
|
|
|
114
114
|
}
|
|
115
115
|
{
|
|
116
116
|
_map = remove(_map)("49")
|
|
117
|
-
if (_map ===
|
|
117
|
+
if (_map === null) { throw null }
|
|
118
118
|
const r = jsonStr(_map)
|
|
119
119
|
if (r !==
|
|
120
120
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -124,7 +124,7 @@ const test = () => {
|
|
|
124
124
|
}
|
|
125
125
|
{
|
|
126
126
|
_map = remove(_map)("64")
|
|
127
|
-
if (_map ===
|
|
127
|
+
if (_map === null) { throw null }
|
|
128
128
|
const r = jsonStr(_map)
|
|
129
129
|
if (r !==
|
|
130
130
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -134,7 +134,7 @@ const test = () => {
|
|
|
134
134
|
}
|
|
135
135
|
{
|
|
136
136
|
_map = remove(_map)("81")
|
|
137
|
-
if (_map ===
|
|
137
|
+
if (_map === null) { throw null }
|
|
138
138
|
const r = jsonStr(_map)
|
|
139
139
|
if (r !==
|
|
140
140
|
'[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -144,7 +144,7 @@ const test = () => {
|
|
|
144
144
|
}
|
|
145
145
|
{
|
|
146
146
|
_map = remove(_map)("100")
|
|
147
|
-
if (_map ===
|
|
147
|
+
if (_map === null) { throw null }
|
|
148
148
|
const r = jsonStr(_map)
|
|
149
149
|
if (r !==
|
|
150
150
|
'[[[["1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -154,7 +154,7 @@ const test = () => {
|
|
|
154
154
|
}
|
|
155
155
|
{
|
|
156
156
|
_map = remove(_map)("121")
|
|
157
|
-
if (_map ===
|
|
157
|
+
if (_map === null) { throw null }
|
|
158
158
|
const r = jsonStr(_map)
|
|
159
159
|
if (r !==
|
|
160
160
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -164,7 +164,7 @@ const test = () => {
|
|
|
164
164
|
}
|
|
165
165
|
{
|
|
166
166
|
_map = remove(_map)("144")
|
|
167
|
-
if (_map ===
|
|
167
|
+
if (_map === null) { throw null }
|
|
168
168
|
const r = jsonStr(_map)
|
|
169
169
|
if (r !==
|
|
170
170
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -174,7 +174,7 @@ const test = () => {
|
|
|
174
174
|
}
|
|
175
175
|
{
|
|
176
176
|
_map = remove(_map)("169")
|
|
177
|
-
if (_map ===
|
|
177
|
+
if (_map === null) { throw null }
|
|
178
178
|
const r = jsonStr(_map)
|
|
179
179
|
if (r !==
|
|
180
180
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"196",["225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -184,7 +184,7 @@ const test = () => {
|
|
|
184
184
|
}
|
|
185
185
|
{
|
|
186
186
|
_map = remove(_map)("196")
|
|
187
|
-
if (_map ===
|
|
187
|
+
if (_map === null) { throw null }
|
|
188
188
|
const r = jsonStr(_map)
|
|
189
189
|
if (r !==
|
|
190
190
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -194,7 +194,7 @@ const test = () => {
|
|
|
194
194
|
}
|
|
195
195
|
{
|
|
196
196
|
_map = remove(_map)("225")
|
|
197
|
-
if (_map ===
|
|
197
|
+
if (_map === null) { throw null }
|
|
198
198
|
const r = jsonStr(_map)
|
|
199
199
|
if (r !==
|
|
200
200
|
'[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
|
|
@@ -204,7 +204,7 @@ const test = () => {
|
|
|
204
204
|
}
|
|
205
205
|
{
|
|
206
206
|
_map = remove(_map)("256")
|
|
207
|
-
if (_map ===
|
|
207
|
+
if (_map === null) { throw null }
|
|
208
208
|
const r = jsonStr(_map)
|
|
209
209
|
if (r !==
|
|
210
210
|
'[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"289",[["324","361"],"400",["441","484"]]],' +
|
|
@@ -214,7 +214,7 @@ const test = () => {
|
|
|
214
214
|
}
|
|
215
215
|
{
|
|
216
216
|
_map = remove(_map)("289")
|
|
217
|
-
if (_map ===
|
|
217
|
+
if (_map === null) { throw null }
|
|
218
218
|
const r = jsonStr(_map)
|
|
219
219
|
if (r !==
|
|
220
220
|
'[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"324",[["361"],"400",["441","484"]]],' +
|
|
@@ -224,7 +224,7 @@ const test = () => {
|
|
|
224
224
|
}
|
|
225
225
|
{
|
|
226
226
|
_map = remove(_map)("324")
|
|
227
|
-
if (_map ===
|
|
227
|
+
if (_map === null) { throw null }
|
|
228
228
|
const r = jsonStr(_map)
|
|
229
229
|
if (r !==
|
|
230
230
|
'[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"361",[["400"],"441",["484"]]],' +
|
|
@@ -234,7 +234,7 @@ const test = () => {
|
|
|
234
234
|
}
|
|
235
235
|
{
|
|
236
236
|
_map = remove(_map)("361")
|
|
237
|
-
if (_map ===
|
|
237
|
+
if (_map === null) { throw null }
|
|
238
238
|
const r = jsonStr(_map)
|
|
239
239
|
if (r !==
|
|
240
240
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"400",["441","484"]]],' +
|
|
@@ -244,7 +244,7 @@ const test = () => {
|
|
|
244
244
|
}
|
|
245
245
|
{
|
|
246
246
|
_map = remove(_map)("400")
|
|
247
|
-
if (_map ===
|
|
247
|
+
if (_map === null) { throw null }
|
|
248
248
|
const r = jsonStr(_map)
|
|
249
249
|
if (r !==
|
|
250
250
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"441",["484"]]],' +
|
|
@@ -254,7 +254,7 @@ const test = () => {
|
|
|
254
254
|
}
|
|
255
255
|
{
|
|
256
256
|
_map = remove(_map)("441")
|
|
257
|
-
if (_map ===
|
|
257
|
+
if (_map === null) { throw null }
|
|
258
258
|
const r = jsonStr(_map)
|
|
259
259
|
if (r !==
|
|
260
260
|
'[[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["484"]]],' +
|
|
@@ -264,7 +264,7 @@ const test = () => {
|
|
|
264
264
|
}
|
|
265
265
|
{
|
|
266
266
|
_map = remove(_map)("484")
|
|
267
|
-
if (_map ===
|
|
267
|
+
if (_map === null) { throw null }
|
|
268
268
|
const r = jsonStr(_map)
|
|
269
269
|
if (r !==
|
|
270
270
|
'[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],' +
|
|
@@ -276,7 +276,7 @@ const test = () => {
|
|
|
276
276
|
}
|
|
277
277
|
{
|
|
278
278
|
_map = remove(_map)("529")
|
|
279
|
-
if (_map ===
|
|
279
|
+
if (_map === null) { throw null }
|
|
280
280
|
const r = jsonStr(_map)
|
|
281
281
|
if (r !==
|
|
282
282
|
'[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"576",["625","676"]],' +
|
|
@@ -286,7 +286,7 @@ const test = () => {
|
|
|
286
286
|
}
|
|
287
287
|
{
|
|
288
288
|
_map = remove(_map)("576")
|
|
289
|
-
if (_map ===
|
|
289
|
+
if (_map === null) { throw null }
|
|
290
290
|
const r = jsonStr(_map)
|
|
291
291
|
if (r !==
|
|
292
292
|
'[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"625",["676"]],' +
|
|
@@ -296,7 +296,7 @@ const test = () => {
|
|
|
296
296
|
}
|
|
297
297
|
{
|
|
298
298
|
_map = remove(_map)("625")
|
|
299
|
-
if (_map ===
|
|
299
|
+
if (_map === null) { throw null }
|
|
300
300
|
const r = jsonStr(_map)
|
|
301
301
|
if (r !==
|
|
302
302
|
'[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["676"]],' +
|
|
@@ -306,7 +306,7 @@ const test = () => {
|
|
|
306
306
|
}
|
|
307
307
|
{
|
|
308
308
|
_map = remove(_map)("676")
|
|
309
|
-
if (_map ===
|
|
309
|
+
if (_map === null) { throw null }
|
|
310
310
|
const r = jsonStr(_map)
|
|
311
311
|
if (r !==
|
|
312
312
|
'[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],' +
|
|
@@ -316,7 +316,7 @@ const test = () => {
|
|
|
316
316
|
}
|
|
317
317
|
{
|
|
318
318
|
_map = remove(_map)("729")
|
|
319
|
-
if (_map ===
|
|
319
|
+
if (_map === null) { throw null }
|
|
320
320
|
const r = jsonStr(_map)
|
|
321
321
|
if (r !==
|
|
322
322
|
'[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],' +
|
|
@@ -326,7 +326,7 @@ const test = () => {
|
|
|
326
326
|
}
|
|
327
327
|
{
|
|
328
328
|
_map = remove(_map)("784")
|
|
329
|
-
if (_map ===
|
|
329
|
+
if (_map === null) { throw null }
|
|
330
330
|
const r = jsonStr(_map)
|
|
331
331
|
if (r !==
|
|
332
332
|
'[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"841",["900","961"]]]'
|
|
@@ -334,7 +334,7 @@ const test = () => {
|
|
|
334
334
|
}
|
|
335
335
|
{
|
|
336
336
|
_map = remove(_map)("841")
|
|
337
|
-
if (_map ===
|
|
337
|
+
if (_map === null) { throw null }
|
|
338
338
|
const r = jsonStr(_map)
|
|
339
339
|
if (r !==
|
|
340
340
|
'[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"900",["961"]]]'
|
|
@@ -342,7 +342,7 @@ const test = () => {
|
|
|
342
342
|
}
|
|
343
343
|
{
|
|
344
344
|
_map = remove(_map)("900")
|
|
345
|
-
if (_map ===
|
|
345
|
+
if (_map === null) { throw null }
|
|
346
346
|
const r = jsonStr(_map)
|
|
347
347
|
if (r !==
|
|
348
348
|
'[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["961"]]]'
|
|
@@ -350,7 +350,7 @@ const test = () => {
|
|
|
350
350
|
}
|
|
351
351
|
{
|
|
352
352
|
_map = remove(_map)("961")
|
|
353
|
-
if (_map ===
|
|
353
|
+
if (_map === null) { throw null }
|
|
354
354
|
const r = jsonStr(_map)
|
|
355
355
|
if (r !==
|
|
356
356
|
'[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]]'
|
|
@@ -358,7 +358,7 @@ const test = () => {
|
|
|
358
358
|
}
|
|
359
359
|
{
|
|
360
360
|
_map = remove(_map)("1024")
|
|
361
|
-
if (_map ===
|
|
361
|
+
if (_map === null) { throw null }
|
|
362
362
|
const r = jsonStr(_map)
|
|
363
363
|
if (r !==
|
|
364
364
|
'[["1089"],"1156",["1225"],"1296",["1369","1444"]]'
|
|
@@ -366,7 +366,7 @@ const test = () => {
|
|
|
366
366
|
}
|
|
367
367
|
{
|
|
368
368
|
_map = remove(_map)("1089")
|
|
369
|
-
if (_map ===
|
|
369
|
+
if (_map === null) { throw null }
|
|
370
370
|
const r = jsonStr(_map)
|
|
371
371
|
if (r !==
|
|
372
372
|
'[["1156","1225"],"1296",["1369","1444"]]'
|
|
@@ -374,7 +374,7 @@ const test = () => {
|
|
|
374
374
|
}
|
|
375
375
|
{
|
|
376
376
|
_map = remove(_map)("1156")
|
|
377
|
-
if (_map ===
|
|
377
|
+
if (_map === null) { throw null }
|
|
378
378
|
const r = jsonStr(_map)
|
|
379
379
|
if (r !==
|
|
380
380
|
'[["1225"],"1296",["1369","1444"]]'
|
|
@@ -382,7 +382,7 @@ const test = () => {
|
|
|
382
382
|
}
|
|
383
383
|
{
|
|
384
384
|
_map = remove(_map)("1225")
|
|
385
|
-
if (_map ===
|
|
385
|
+
if (_map === null) { throw null }
|
|
386
386
|
const r = jsonStr(_map)
|
|
387
387
|
if (r !==
|
|
388
388
|
'[["1296"],"1369",["1444"]]'
|
|
@@ -390,7 +390,7 @@ const test = () => {
|
|
|
390
390
|
}
|
|
391
391
|
{
|
|
392
392
|
_map = remove(_map)("1296")
|
|
393
|
-
if (_map ===
|
|
393
|
+
if (_map === null) { throw null }
|
|
394
394
|
const r = jsonStr(_map)
|
|
395
395
|
if (r !==
|
|
396
396
|
'["1369","1444"]'
|
|
@@ -398,18 +398,18 @@ const test = () => {
|
|
|
398
398
|
}
|
|
399
399
|
{
|
|
400
400
|
_map = remove(_map)("1369")
|
|
401
|
-
if (_map ===
|
|
401
|
+
if (_map === null) { throw null }
|
|
402
402
|
const r = jsonStr(_map)
|
|
403
403
|
if (r !== '["1444"]') { throw r }
|
|
404
404
|
}
|
|
405
405
|
{
|
|
406
406
|
_map = remove(_map)("1444")
|
|
407
|
-
if (_map !==
|
|
407
|
+
if (_map !== null) { throw _map }
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
const test2 = () => {
|
|
412
|
-
/** @type {btree.Node<string>|
|
|
412
|
+
/** @type {btree.Node<string>|null} */
|
|
413
413
|
let _map = ['1']
|
|
414
414
|
for (let i = 2; i <= 10; i++)
|
|
415
415
|
_map = set(_map)((i * i).toString())
|
|
@@ -419,70 +419,70 @@ const test2 = () => {
|
|
|
419
419
|
|
|
420
420
|
{
|
|
421
421
|
_map = remove(_map)("4")
|
|
422
|
-
if (_map ===
|
|
422
|
+
if (_map === null) { throw _map }
|
|
423
423
|
_s = jsonStr(_map);
|
|
424
424
|
if (_s !== '[[["1","100"],"16",["25","36"]],"49",[["64"],"81",["9"]]]') { throw _s }
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
{
|
|
428
428
|
_map = remove(_map)("49")
|
|
429
|
-
if (_map ===
|
|
429
|
+
if (_map === null) { throw _map }
|
|
430
430
|
_s = jsonStr(_map);
|
|
431
431
|
if (_s !== '[["1","100"],"16",["25","36"],"64",["81","9"]]') { throw _s }
|
|
432
432
|
}
|
|
433
433
|
|
|
434
434
|
{
|
|
435
435
|
_map = remove(_map)("64")
|
|
436
|
-
if (_map ===
|
|
436
|
+
if (_map === null) { throw _map }
|
|
437
437
|
_s = jsonStr(_map);
|
|
438
438
|
if (_s !== '[["1","100"],"16",["25","36"],"81",["9"]]') { throw _s }
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
{
|
|
442
442
|
_map = remove(_map)("81")
|
|
443
|
-
if (_map ===
|
|
443
|
+
if (_map === null) { throw _map }
|
|
444
444
|
_s = jsonStr(_map);
|
|
445
445
|
if (_s !== '[["1","100"],"16",["25"],"36",["9"]]') { throw _s }
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
{
|
|
449
449
|
_map = remove(_map)("36")
|
|
450
|
-
if (_map ===
|
|
450
|
+
if (_map === null) { throw _map }
|
|
451
451
|
_s = jsonStr(_map);
|
|
452
452
|
if (_s !== '[["1","100"],"16",["25","9"]]') { throw _s }
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
{
|
|
456
456
|
_map = remove(_map)("16")
|
|
457
|
-
if (_map ===
|
|
457
|
+
if (_map === null) { throw _map }
|
|
458
458
|
_s = jsonStr(_map);
|
|
459
459
|
if (_s !== '[["1","100"],"25",["9"]]') { throw _s }
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
{
|
|
463
463
|
_map = remove(_map)("25")
|
|
464
|
-
if (_map ===
|
|
464
|
+
if (_map === null) { throw _map }
|
|
465
465
|
_s = jsonStr(_map);
|
|
466
466
|
if (_s !== '[["1"],"100",["9"]]') { throw _s }
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
{
|
|
470
470
|
_map = remove(_map)("100")
|
|
471
|
-
if (_map ===
|
|
471
|
+
if (_map === null) { throw _map }
|
|
472
472
|
_s = jsonStr(_map);
|
|
473
473
|
if (_s !== '["1","9"]') { throw _s }
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
{
|
|
477
477
|
_map = remove(_map)("9")
|
|
478
|
-
if (_map ===
|
|
478
|
+
if (_map === null) { throw _map }
|
|
479
479
|
_s = jsonStr(_map);
|
|
480
480
|
if (_s !== '["1"]') { throw _s }
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
{
|
|
484
484
|
_map = remove(_map)("1")
|
|
485
|
-
if (_map !==
|
|
485
|
+
if (_map !== null) { throw _map }
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
|
|
@@ -36,7 +36,7 @@ const reduceOp = ([i, x]) => a => {
|
|
|
36
36
|
|
|
37
37
|
const reduceBranch = fold(reduceOp)
|
|
38
38
|
|
|
39
|
-
/** @type {<T>(c: cmp.Compare<T>) => (g: (value
|
|
39
|
+
/** @type {<T>(c: cmp.Compare<T>) => (g: (value: T | null) => T) => (node: _.Node<T>) => _.Node<T>} */
|
|
40
40
|
const nodeSet = c => g => node => {
|
|
41
41
|
const { first, tail } = find(c)(node)
|
|
42
42
|
const [i, x] = first;
|
|
@@ -46,7 +46,7 @@ const nodeSet = c => g => node => {
|
|
|
46
46
|
switch (i) {
|
|
47
47
|
case 0: {
|
|
48
48
|
// insert
|
|
49
|
-
const value = g()
|
|
49
|
+
const value = g(null)
|
|
50
50
|
switch (x.length) {
|
|
51
51
|
case 1: { return [[value, x[0]]] }
|
|
52
52
|
case 2: { return [[value], x[0], [x[1]]] }
|
|
@@ -63,7 +63,7 @@ const nodeSet = c => g => node => {
|
|
|
63
63
|
}
|
|
64
64
|
case 2: {
|
|
65
65
|
// insert
|
|
66
|
-
const value = g()
|
|
66
|
+
const value = g(null)
|
|
67
67
|
switch (x.length) {
|
|
68
68
|
case 1: { return [[x[0], value]] }
|
|
69
69
|
case 2: { return [[x[0]], value, [x[1]]] }
|
|
@@ -79,7 +79,7 @@ const nodeSet = c => g => node => {
|
|
|
79
79
|
case 4: {
|
|
80
80
|
// insert
|
|
81
81
|
const [v0, v1] = x;
|
|
82
|
-
return [[v0], v1, [g()]]
|
|
82
|
+
return [[v0], v1, [g(null)]]
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -87,8 +87,8 @@ const nodeSet = c => g => node => {
|
|
|
87
87
|
return r.length === 1 ? r[0] : r
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
/** @type {<T>(c: cmp.Compare<T>) => (f: (value
|
|
91
|
-
const set = c => f => tree => tree ===
|
|
90
|
+
/** @type {<T>(c: cmp.Compare<T>) => (f: (value: T|null) => T) => (tree: _.Tree<T>) => _.Node<T>} */
|
|
91
|
+
const set = c => f => tree => tree === null ? [f(null)] : nodeSet(c)(f)(tree)
|
|
92
92
|
|
|
93
93
|
module.exports = {
|
|
94
94
|
/** @readonly */
|
package/types/btree/test.f.cjs
CHANGED
|
@@ -55,7 +55,7 @@ const find = () => {
|
|
|
55
55
|
_map = set(_map)('b')
|
|
56
56
|
_map = set(_map)('c')
|
|
57
57
|
const result = f.value(f.find(cmp('e'))(_map).first)
|
|
58
|
-
if (result !==
|
|
58
|
+
if (result !== null) { throw result }
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const test = () => {
|
|
@@ -70,7 +70,7 @@ const test = () => {
|
|
|
70
70
|
{
|
|
71
71
|
/** @type {list.Result<string>} */
|
|
72
72
|
let _item = list.next(values(_map))
|
|
73
|
-
while (_item !==
|
|
73
|
+
while (_item !== null) {
|
|
74
74
|
_item = list.next(_item.tail)
|
|
75
75
|
}
|
|
76
76
|
}
|