functionalscript 0.3.7 → 0.3.9
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.js +0 -1
- package/com/cs/module.f.js +5 -6
- package/com/rust/module.f.d.ts +3 -3
- package/com/rust/module.f.js +24 -29
- package/com/test/build.f.js +2 -2
- package/com/types/module.f.d.ts +1 -1
- package/com/types/module.f.js +1 -2
- package/com/types/testlib.f.js +0 -1
- package/commonjs/build/module.f.d.ts +2 -2
- package/commonjs/build/module.f.js +3 -6
- package/commonjs/build/test.f.js +0 -4
- package/commonjs/module/function/module.f.d.ts +1 -1
- package/commonjs/module/function/module.f.js +1 -1
- package/commonjs/module/module.f.d.ts +1 -1
- package/commonjs/module/module.f.js +2 -3
- package/commonjs/path/module.f.d.ts +5 -5
- package/commonjs/path/module.f.js +6 -8
- package/commonjs/path/test.f.js +1 -2
- package/crypto/prime_field/module.f.d.ts +1 -1
- package/crypto/prime_field/module.f.js +1 -1
- package/crypto/secp/module.f.d.ts +1 -1
- package/crypto/secp/module.f.js +2 -2
- package/crypto/sha2/module.f.d.ts +75 -12
- package/crypto/sha2/module.f.js +246 -139
- package/crypto/sha2/test.f.d.ts +22 -3
- package/crypto/sha2/test.f.js +120 -67
- package/dev/test/module.f.d.ts +1 -1
- package/dev/test/module.f.js +4 -5
- package/dev/test.f.js +0 -4
- package/djs/module.f.d.ts +1 -1
- package/djs/module.f.js +0 -1
- package/djs/parser/module.f.d.ts +1 -1
- package/djs/parser/module.f.js +0 -2
- package/djs/serializer/module.f.d.ts +2 -2
- package/djs/serializer/module.f.js +0 -2
- package/djs/tokenizer/module.f.js +0 -1
- package/fsc/test.f.js +0 -1
- package/js/tokenizer/module.f.d.ts +1 -1
- package/js/tokenizer/module.f.js +1 -1
- package/json/parser/module.f.d.ts +2 -2
- package/json/parser/module.f.js +0 -3
- package/json/serializer/module.f.js +0 -2
- package/json/tokenizer/module.f.js +0 -1
- package/package.json +1 -1
- package/text/ascii/module.f.d.ts +1 -1
- package/text/ascii/module.f.js +2 -3
- package/text/ascii/test.f.js +2 -4
- package/text/module.f.d.ts +18 -3
- package/text/module.f.js +22 -6
- package/text/sgr/module.f.js +1 -1
- package/text/test.f.d.ts +4 -1
- package/text/test.f.js +24 -16
- package/text/utf16/module.f.d.ts +5 -6
- package/text/utf16/module.f.js +9 -10
- package/text/utf16/test.f.js +29 -30
- package/text/utf8/module.f.d.ts +8 -5
- package/text/utf8/module.f.js +3 -5
- package/text/utf8/test.f.js +34 -35
- package/types/bigfloat/module.f.js +1 -1
- package/types/bigint/module.f.d.ts +36 -7
- package/types/bigint/module.f.js +40 -11
- package/types/bigint/test.f.d.ts +8 -0
- package/types/bigint/test.f.js +81 -2
- package/types/bit_vec/module.f.d.ts +103 -83
- package/types/bit_vec/module.f.js +68 -110
- package/types/bit_vec/test.f.d.ts +20 -8
- package/types/bit_vec/test.f.js +110 -117
- package/types/btree/find/module.f.d.ts +11 -10
- package/types/btree/find/module.f.js +1 -5
- package/types/btree/find/test.f.js +4 -6
- package/types/btree/module.f.d.ts +3 -3
- package/types/btree/module.f.js +2 -5
- package/types/btree/remove/module.f.d.ts +2 -2
- package/types/btree/remove/module.f.js +0 -3
- package/types/btree/remove/test.f.js +4 -7
- package/types/btree/set/module.f.d.ts +2 -2
- package/types/btree/set/module.f.js +2 -6
- package/types/btree/set/test.f.js +3 -6
- package/types/btree/test.f.js +9 -13
- package/types/btree/types/module.f.d.ts +1 -3
- package/types/byte_set/module.f.d.ts +3 -3
- package/types/byte_set/module.f.js +1 -4
- package/types/byte_set/test.f.js +2 -4
- package/types/function/compare/module.f.d.ts +1 -5
- package/types/function/compare/module.f.js +0 -1
- package/types/function/compare/test.f.js +1 -2
- package/types/function/module.f.d.ts +1 -1
- package/types/function/module.f.js +1 -1
- package/types/function/operator/module.f.d.ts +2 -3
- package/types/function/operator/module.f.js +5 -5
- package/types/function/test.f.js +1 -2
- package/types/list/module.f.d.ts +1 -1
- package/types/list/module.f.js +9 -9
- package/types/list/test.f.js +2 -4
- package/types/map/module.f.d.ts +7 -9
- package/types/map/module.f.js +6 -15
- package/types/map/test.f.js +3 -4
- package/types/nibble_set/module.f.d.ts +2 -3
- package/types/nibble_set/test.f.js +26 -27
- package/types/nullable/test.f.js +2 -2
- package/types/number/module.f.d.ts +2 -2
- package/types/number/module.f.js +1 -2
- package/types/number/test.f.js +1 -2
- package/types/object/module.f.d.ts +5 -5
- package/types/object/module.f.js +2 -4
- package/types/object/test.f.js +3 -3
- package/types/range/test.f.js +6 -6
- package/types/range_map/module.f.d.ts +8 -8
- package/types/range_map/module.f.js +3 -9
- package/types/range_map/test.f.js +2 -4
- package/types/result/module.f.d.ts +2 -3
- package/types/sorted_list/module.f.d.ts +8 -8
- package/types/sorted_list/module.f.js +2 -6
- package/types/sorted_list/test.f.js +12 -17
- package/types/sorted_set/module.f.d.ts +2 -2
- package/types/sorted_set/module.f.js +2 -5
- package/types/sorted_set/test.f.js +14 -19
- package/types/string/module.f.d.ts +5 -5
- package/types/string/module.f.js +2 -4
- package/types/string/test.f.js +2 -4
- package/types/string_set/module.f.d.ts +2 -2
- package/types/string_set/module.f.js +5 -11
- package/types/string_set/test.f.js +25 -25
package/types/bit_vec/test.f.js
CHANGED
|
@@ -1,4 +1,73 @@
|
|
|
1
|
-
import { empty, vec, length,
|
|
1
|
+
import { empty, vec, length, uint, lsb, msb } from "./module.f.js";
|
|
2
|
+
const frontTest = (e) => (r0) => (r1) => () => {
|
|
3
|
+
const vector = vec(8n)(0xf5n); // 0x1F5n
|
|
4
|
+
if (vector !== 0x1f5n) {
|
|
5
|
+
throw vector;
|
|
6
|
+
}
|
|
7
|
+
const result = e.front(4n)(vector);
|
|
8
|
+
if (result !== r0) {
|
|
9
|
+
throw result;
|
|
10
|
+
}
|
|
11
|
+
const result2 = e.front(16n)(vector);
|
|
12
|
+
if (result2 !== r1) {
|
|
13
|
+
throw result2;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const popFront = (e) => ([r00, r01]) => ([r10, r11]) => () => {
|
|
17
|
+
const vector = vec(8n)(0xf5n); // 0x1F5n
|
|
18
|
+
const [result, rest] = e.popFront(4n)(vector);
|
|
19
|
+
if (result !== r00) {
|
|
20
|
+
throw result;
|
|
21
|
+
}
|
|
22
|
+
if (rest !== r01) {
|
|
23
|
+
throw rest;
|
|
24
|
+
}
|
|
25
|
+
const [result2, rest2] = e.popFront(16n)(vector);
|
|
26
|
+
if (result2 !== r10) {
|
|
27
|
+
throw result2;
|
|
28
|
+
}
|
|
29
|
+
if (rest2 !== r11) {
|
|
30
|
+
throw rest2;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const removeFront = (e) => (r0) => (r1) => () => {
|
|
34
|
+
const v = vec(16n)(0x3456n); // 0x13456n
|
|
35
|
+
if (v !== 0x13456n) {
|
|
36
|
+
throw v;
|
|
37
|
+
}
|
|
38
|
+
const r = e.removeFront(4n)(v);
|
|
39
|
+
if (r !== r0) {
|
|
40
|
+
throw r;
|
|
41
|
+
}
|
|
42
|
+
const r2 = e.removeFront(24n)(v);
|
|
43
|
+
if (r2 !== r1) {
|
|
44
|
+
throw r2;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const concat = (e) => (r) => () => {
|
|
48
|
+
const u8 = vec(8n);
|
|
49
|
+
const a = u8(0x45n); // 0x145n
|
|
50
|
+
if (a !== 0x145n) {
|
|
51
|
+
throw a;
|
|
52
|
+
}
|
|
53
|
+
const b = u8(0x89n); // 0x189n
|
|
54
|
+
if (b !== 0x189n) {
|
|
55
|
+
throw b;
|
|
56
|
+
}
|
|
57
|
+
const ab = e.concat(a)(b); // 0x18945n
|
|
58
|
+
if (ab !== r) {
|
|
59
|
+
throw ab;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const assertEq = (a, b) => {
|
|
63
|
+
if (a !== b) {
|
|
64
|
+
throw [a, b];
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const assertEq2 = ([a0, a1], [b0, b1]) => {
|
|
68
|
+
assertEq(a0, b0);
|
|
69
|
+
assertEq(a1, b1);
|
|
70
|
+
};
|
|
2
71
|
export default {
|
|
3
72
|
examples: {
|
|
4
73
|
vec: () => {
|
|
@@ -22,130 +91,54 @@ export default {
|
|
|
22
91
|
throw result;
|
|
23
92
|
}
|
|
24
93
|
},
|
|
25
|
-
|
|
94
|
+
front: () => {
|
|
26
95
|
const vector = vec(8n)(0xf5n); // 0x1F5n
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (result !== 5n) {
|
|
32
|
-
throw result;
|
|
33
|
-
}
|
|
34
|
-
const result2 = uintLsb(16n)(vector); // result2 is 0xF5n
|
|
35
|
-
if (result2 !== 0xf5n) {
|
|
36
|
-
throw result2;
|
|
37
|
-
}
|
|
96
|
+
assertEq(lsb.front(4n)(vector), 5n);
|
|
97
|
+
assertEq(lsb.front(16n)(vector), 0xf5n);
|
|
98
|
+
assertEq(msb.front(4n)(vector), 0xfn);
|
|
99
|
+
assertEq(msb.front(16n)(vector), 0xf500n);
|
|
38
100
|
},
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (result !== 0xfn) {
|
|
46
|
-
throw result;
|
|
47
|
-
}
|
|
48
|
-
const result2 = uintMsb(16n)(vector); // result2 is 0xF500n
|
|
49
|
-
if (result2 !== 0xf500n) {
|
|
50
|
-
throw result2;
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
popUintLsb: () => {
|
|
54
|
-
const vector = vec(8n)(0xf5n); // 0x1F5n
|
|
55
|
-
const [result, rest] = popUintLsb(4n)(vector); // result is 5n, rest is 0x1Fn
|
|
56
|
-
if (result !== 5n) {
|
|
57
|
-
throw result;
|
|
58
|
-
}
|
|
59
|
-
if (rest !== 0x1fn) {
|
|
60
|
-
throw rest;
|
|
61
|
-
}
|
|
62
|
-
const [result2, rest2] = popUintLsb(16n)(vector); // result2 is 0xF5n, rest2 is 1n
|
|
63
|
-
if (result2 !== 0xf5n) {
|
|
64
|
-
throw result2;
|
|
65
|
-
}
|
|
66
|
-
if (rest2 !== 1n) {
|
|
67
|
-
throw rest2;
|
|
68
|
-
}
|
|
101
|
+
removeFront: () => {
|
|
102
|
+
const v = vec(16n)(0x3456n); // 0x13456n
|
|
103
|
+
assertEq(lsb.removeFront(4n)(v), 0x1345n);
|
|
104
|
+
assertEq(lsb.removeFront(24n)(v), 0x1n);
|
|
105
|
+
assertEq(msb.removeFront(4n)(v), 0x1456n);
|
|
106
|
+
assertEq(msb.removeFront(24n)(v), 0x1n);
|
|
69
107
|
},
|
|
70
|
-
|
|
108
|
+
popFront: () => {
|
|
71
109
|
const vector = vec(8n)(0xf5n); // 0x1F5n
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (rest !== 0x15n) {
|
|
77
|
-
throw rest;
|
|
78
|
-
}
|
|
79
|
-
const [result2, rest2] = popUintMsb(16n)(vector); // [0xF500n, 1n]
|
|
80
|
-
if (result2 !== 0xf500n) {
|
|
81
|
-
throw result2;
|
|
82
|
-
}
|
|
83
|
-
if (rest2 !== 1n) {
|
|
84
|
-
throw rest2;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
concatLsb: () => {
|
|
88
|
-
const u8 = vec(8n);
|
|
89
|
-
const a = u8(0x45n); // 0x145n
|
|
90
|
-
if (a !== 0x145n) {
|
|
91
|
-
throw a;
|
|
92
|
-
}
|
|
93
|
-
const b = u8(0x89n); // 0x189n
|
|
94
|
-
if (b !== 0x189n) {
|
|
95
|
-
throw b;
|
|
96
|
-
}
|
|
97
|
-
const ab = concatLsb(a)(b); // 0x18945n
|
|
98
|
-
if (ab !== 0x18945n) {
|
|
99
|
-
throw ab;
|
|
100
|
-
}
|
|
110
|
+
assertEq2(lsb.popFront(4n)(vector), [5n, 0x1fn]);
|
|
111
|
+
assertEq2(lsb.popFront(16n)(vector), [0xf5n, 1n]);
|
|
112
|
+
assertEq2(msb.popFront(4n)(vector), [0xfn, 0x15n]);
|
|
113
|
+
assertEq2(msb.popFront(16n)(vector), [0xf500n, 1n]);
|
|
101
114
|
},
|
|
102
|
-
|
|
115
|
+
concat: () => {
|
|
103
116
|
const u8 = vec(8n);
|
|
104
117
|
const a = u8(0x45n); // 0x145n
|
|
105
|
-
if (a !== 0x145n) {
|
|
106
|
-
throw a;
|
|
107
|
-
}
|
|
108
118
|
const b = u8(0x89n); // 0x189n
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
const ab = concatMsb(a)(b); // 0x14589n
|
|
113
|
-
if (ab !== 0x14589n) {
|
|
114
|
-
throw ab;
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
removeLsb: () => {
|
|
118
|
-
const v = vec(16n)(0x3456n); // 0x13456n
|
|
119
|
-
if (v !== 0x13456n) {
|
|
120
|
-
throw v;
|
|
121
|
-
}
|
|
122
|
-
const r = removeLsb(4n)(v); // 0x1345n
|
|
123
|
-
if (r !== 0x1345n) {
|
|
124
|
-
throw r;
|
|
125
|
-
}
|
|
126
|
-
const r2 = removeLsb(24n)(v); // 0x1n
|
|
127
|
-
if (r2 !== 0x1n) {
|
|
128
|
-
throw r2;
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
removeMsb: () => {
|
|
132
|
-
const v = vec(16n)(0x3456n); // 0x13456n
|
|
133
|
-
if (v !== 0x13456n) {
|
|
134
|
-
throw v;
|
|
135
|
-
}
|
|
136
|
-
const r = removeMsb(4n)(v); // 0x1456n
|
|
137
|
-
if (r !== 0x1456n) {
|
|
138
|
-
throw r;
|
|
139
|
-
}
|
|
140
|
-
const r2 = removeMsb(24n)(v); // 0x1n
|
|
141
|
-
if (r2 !== 0x1n) {
|
|
142
|
-
throw r2;
|
|
143
|
-
}
|
|
119
|
+
assertEq(lsb.concat(a)(b), 0x18945n);
|
|
120
|
+
assertEq(msb.concat(a)(b), 0x14589n);
|
|
144
121
|
}
|
|
145
122
|
},
|
|
123
|
+
front: {
|
|
124
|
+
lsbf: frontTest(lsb)(5n)(0xf5n),
|
|
125
|
+
msbf: frontTest(msb)(0xfn)(0xf500n),
|
|
126
|
+
},
|
|
127
|
+
popFront: {
|
|
128
|
+
lsbm: popFront(lsb)([5n, 0x1fn])([0xf5n, 1n]),
|
|
129
|
+
msbm: popFront(msb)([0xfn, 0x15n])([0xf500n, 1n]),
|
|
130
|
+
},
|
|
131
|
+
removeFront: {
|
|
132
|
+
lsbm: removeFront(lsb)(0x1345n)(0x1n),
|
|
133
|
+
msbm: removeFront(msb)(0x1456n)(0x1n),
|
|
134
|
+
},
|
|
135
|
+
concat: {
|
|
136
|
+
lsbm: concat(lsb)(0x18945n),
|
|
137
|
+
msbm: concat(msb)(0x14589n),
|
|
138
|
+
},
|
|
146
139
|
uintLsb: () => {
|
|
147
140
|
const vector = 117n;
|
|
148
|
-
const extract3Bits =
|
|
141
|
+
const extract3Bits = lsb.front(3n);
|
|
149
142
|
const result = extract3Bits(vector); // result is 0b101n (5n)
|
|
150
143
|
if (result !== 5n) {
|
|
151
144
|
throw result;
|
|
@@ -153,7 +146,7 @@ export default {
|
|
|
153
146
|
},
|
|
154
147
|
uintSmall: () => {
|
|
155
148
|
const vector = 3n;
|
|
156
|
-
const extract3Bits =
|
|
149
|
+
const extract3Bits = lsb.front(3n)(vector);
|
|
157
150
|
if (extract3Bits !== 1n) {
|
|
158
151
|
throw extract3Bits;
|
|
159
152
|
}
|
|
@@ -179,7 +172,7 @@ export default {
|
|
|
179
172
|
if (length(v) !== 8n) {
|
|
180
173
|
throw 'len';
|
|
181
174
|
}
|
|
182
|
-
const u =
|
|
175
|
+
const u = lsb.front(8n)(v);
|
|
183
176
|
if (u !== 0xfen) {
|
|
184
177
|
throw v;
|
|
185
178
|
}
|
|
@@ -188,7 +181,7 @@ export default {
|
|
|
188
181
|
const vec8 = vec(8n);
|
|
189
182
|
const a = vec8(0x345n);
|
|
190
183
|
const b = vec8(0x789n);
|
|
191
|
-
const ab =
|
|
184
|
+
const ab = lsb.concat(a)(b);
|
|
192
185
|
if (ab !== 0x18945n) {
|
|
193
186
|
throw ab;
|
|
194
187
|
}
|
|
@@ -202,7 +195,7 @@ export default {
|
|
|
202
195
|
if (v !== 0x32345n) {
|
|
203
196
|
throw v.toString(16);
|
|
204
197
|
}
|
|
205
|
-
const r =
|
|
198
|
+
const r = lsb.removeFront(9n)(v);
|
|
206
199
|
if (r !== 0x191n) {
|
|
207
200
|
throw r.toString(16);
|
|
208
201
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as List from '../../list/module.f.ts';
|
|
3
|
-
import
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
1
|
+
import type { Leaf1, Leaf2, Branch3, Branch5, TNode } from '../types/module.f.ts';
|
|
2
|
+
import type * as List from '../../list/module.f.ts';
|
|
3
|
+
import { type Compare } from '../../function/compare/module.f.ts';
|
|
4
|
+
import type { Index3, Index5 } from "../../array/module.f.ts";
|
|
5
|
+
type FirstLeaf1<T> = readonly [Index3, Leaf1<T>];
|
|
6
|
+
type FirstBranch3<T> = readonly [1, Branch3<T>];
|
|
7
|
+
type FirstLeaf2<T> = readonly [Index5, Leaf2<T>];
|
|
8
|
+
type FirstBranch5<T> = readonly [1 | 3, Branch5<T>];
|
|
8
9
|
type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T>;
|
|
9
|
-
type PathItem3<T> = readonly [0 | 2,
|
|
10
|
-
type PathItem5<T> = readonly [0 | 2 | 4,
|
|
10
|
+
type PathItem3<T> = readonly [0 | 2, Branch3<T>];
|
|
11
|
+
type PathItem5<T> = readonly [0 | 2 | 4, Branch5<T>];
|
|
11
12
|
export type PathItem<T> = PathItem3<T> | PathItem5<T>;
|
|
12
13
|
export type Path<T> = List.List<PathItem<T>>;
|
|
13
14
|
export type Result<T> = {
|
|
14
15
|
readonly first: First<T>;
|
|
15
16
|
readonly tail: Path<T>;
|
|
16
17
|
};
|
|
17
|
-
export declare const find: <T>(c:
|
|
18
|
+
export declare const find: <T>(c: Compare<T>) => (node: TNode<T>) => Result<T>;
|
|
18
19
|
export declare const isFound: <T>([i]: First<T>) => boolean;
|
|
19
20
|
export declare const value: <T>([i, r]: First<T>) => T | null;
|
|
20
21
|
export {};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as List from "../../list/module.f.js";
|
|
3
|
-
import * as cmp from "../../function/compare/module.f.js";
|
|
4
|
-
const { index3, index5 } = cmp;
|
|
5
|
-
import * as Array from "../../array/module.f.js";
|
|
1
|
+
import { index3, index5 } from "../../function/compare/module.f.js";
|
|
6
2
|
const child = (item) => item[1][item[0]];
|
|
7
3
|
export const find = (c) => {
|
|
8
4
|
const i3 = index3(c);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import * as _ from "./module.f.js";
|
|
2
2
|
import * as list from "../../list/module.f.js";
|
|
3
3
|
import * as json from "../../../json/module.f.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import * as btree from "../types/module.f.js";
|
|
7
|
-
import * as string from "../../string/module.f.js";
|
|
8
|
-
const { cmp } = string;
|
|
4
|
+
import { sort } from "../../object/module.f.js";
|
|
5
|
+
import { cmp } from "../../string/module.f.js";
|
|
9
6
|
import * as s from "../set/module.f.js";
|
|
10
7
|
const jsonStr = json.stringify(sort);
|
|
11
8
|
const set = node => value => s.set(cmp(value))(() => value)(node);
|
|
@@ -13,8 +10,9 @@ const str = r => jsonStr(list.toArray(list.map((x) => x[0])(r)));
|
|
|
13
10
|
const find = i => m => str(_.find(cmp(i))(m));
|
|
14
11
|
const test = () => {
|
|
15
12
|
let _map = ['1'];
|
|
16
|
-
for (let i = 2; i <= 10; i++)
|
|
13
|
+
for (let i = 2; i <= 10; i++) {
|
|
17
14
|
_map = set(_map)((i * i).toString());
|
|
15
|
+
}
|
|
18
16
|
{
|
|
19
17
|
const s = jsonStr(_map);
|
|
20
18
|
if (s !== '[[["1","100"],"16",["25","36"]],"4",[["49"],"64",["81","9"]]]') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { type List } from '../list/module.f.ts';
|
|
2
|
+
import type { Tree } from './types/module.f.ts';
|
|
3
3
|
export declare const empty: null;
|
|
4
|
-
export declare const values: <T>(tree:
|
|
4
|
+
export declare const values: <T>(tree: Tree<T>) => List<T>;
|
package/types/btree/module.f.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import * as n from "../nullable/module.f.js";
|
|
4
|
-
const { map } = n;
|
|
5
|
-
import * as _ from "./types/module.f.js";
|
|
1
|
+
import { flat } from "../list/module.f.js";
|
|
2
|
+
import { map } from "../nullable/module.f.js";
|
|
6
3
|
const nodeValues = node => () => {
|
|
7
4
|
switch (node.length) {
|
|
8
5
|
case 1:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _ from '../types/module.f.ts';
|
|
2
|
-
import * as Cmp from '../../function/compare/module.f.ts';
|
|
1
|
+
import type * as _ from '../types/module.f.ts';
|
|
2
|
+
import type * as Cmp from '../../function/compare/module.f.ts';
|
|
3
3
|
export declare const nodeRemove: <T>(c: Cmp.Compare<T>) => (node: _.TNode<T>) => _.Tree<T>;
|
|
4
4
|
export declare const remove: <T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import * as _ from "../types/module.f.js";
|
|
2
|
-
import * as Cmp from "../../function/compare/module.f.js";
|
|
3
1
|
import * as find from "../find/module.f.js";
|
|
4
2
|
import * as list from "../../list/module.f.js";
|
|
5
3
|
const { fold, concat, next } = list;
|
|
6
|
-
import * as Array from "../../array/module.f.js";
|
|
7
4
|
import * as n from "../../nullable/module.f.js";
|
|
8
5
|
const { map } = n;
|
|
9
6
|
const path = tail => n => {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import * as _ from "./module.f.js";
|
|
2
|
-
import * as BTree from "../types/module.f.js";
|
|
3
2
|
import * as s from "../set/module.f.js";
|
|
4
|
-
import
|
|
5
|
-
const { cmp } = str;
|
|
3
|
+
import { cmp } from "../../string/module.f.js";
|
|
6
4
|
import * as json from "../../../json/module.f.js";
|
|
7
|
-
import
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const remove = node => value => _.nodeRemove(cmp(value))(node);
|
|
5
|
+
import { sort } from "../../object/module.f.js";
|
|
6
|
+
const set = (node) => (value) => s.set(cmp(value))(() => value)(node);
|
|
7
|
+
const remove = (node) => (value) => _.nodeRemove(cmp(value))(node);
|
|
11
8
|
const jsonStr = json.stringify(sort);
|
|
12
9
|
const test = () => {
|
|
13
10
|
let _map = ['1'];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as _ from '../types/module.f.ts';
|
|
2
|
-
import * as Cmp from '../../function/compare/module.f.ts';
|
|
1
|
+
import type * as _ from '../types/module.f.ts';
|
|
2
|
+
import type * as Cmp from '../../function/compare/module.f.ts';
|
|
3
3
|
export declare const set: <T>(c: Cmp.Compare<T>) => (f: (value: T | null) => T) => (tree: _.Tree<T>) => _.TNode<T>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const { find } = btreeFind;
|
|
4
|
-
import * as Cmp from "../../function/compare/module.f.js";
|
|
5
|
-
import * as list from "../../list/module.f.js";
|
|
6
|
-
const { fold } = list;
|
|
1
|
+
import { find } from "../find/module.f.js";
|
|
2
|
+
import { fold } from "../../list/module.f.js";
|
|
7
3
|
const b57 = b => b.length === 5 ? [b] : [[b[0], b[1], b[2]], b[3], [b[4], b[5], b[6]]];
|
|
8
4
|
const reduceOp = ([i, x]) => a => {
|
|
9
5
|
switch (i) {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import * as _ from "./module.f.js";
|
|
2
|
-
import
|
|
3
|
-
import * as s from "../../string/module.f.js";
|
|
4
|
-
const { cmp } = s;
|
|
2
|
+
import { cmp } from "../../string/module.f.js";
|
|
5
3
|
import * as json from "../../../json/module.f.js";
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
const set = node => value => _.set(cmp(value))(() => value)(node);
|
|
4
|
+
import { sort } from "../../object/module.f.js";
|
|
5
|
+
const set = (node) => (value) => _.set(cmp(value))(() => value)(node);
|
|
9
6
|
const jsonStr = json.stringify(sort);
|
|
10
7
|
const test = [
|
|
11
8
|
() => {
|
package/types/btree/test.f.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as _ from "./module.f.js";
|
|
3
|
-
const { values } = _;
|
|
1
|
+
import { values } from "./module.f.js";
|
|
4
2
|
import * as json from "../../json/module.f.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
const { cmp } = str;
|
|
9
|
-
import * as list from "../list/module.f.js";
|
|
3
|
+
import { sort } from "../object/module.f.js";
|
|
4
|
+
import { cmp } from "../string/module.f.js";
|
|
5
|
+
import { next, toArray } from "../list/module.f.js";
|
|
10
6
|
import * as s from "./set/module.f.js";
|
|
11
7
|
import * as f from "./find/module.f.js";
|
|
12
8
|
const jsonStr = json.stringify(sort);
|
|
13
|
-
const stringify = sequence => jsonStr(
|
|
9
|
+
const stringify = sequence => jsonStr(toArray(sequence));
|
|
14
10
|
const set = node => value => s.set(cmp(value))(() => value)(node);
|
|
15
11
|
const valueTest1 = () => {
|
|
16
12
|
let _map = ['a'];
|
|
@@ -19,7 +15,7 @@ const valueTest1 = () => {
|
|
|
19
15
|
_map = set(_map)('d');
|
|
20
16
|
_map = set(_map)('e');
|
|
21
17
|
_map = set(_map)('f');
|
|
22
|
-
|
|
18
|
+
const result = stringify(values(_map));
|
|
23
19
|
if (result !== '["a","b","c","d","e","f"]') {
|
|
24
20
|
throw result;
|
|
25
21
|
}
|
|
@@ -28,7 +24,7 @@ const valuesTest2 = () => {
|
|
|
28
24
|
let _map = ['1'];
|
|
29
25
|
for (let i = 2; i <= 10; i++)
|
|
30
26
|
_map = set(_map)((i * i).toString());
|
|
31
|
-
|
|
27
|
+
const result = stringify(values(_map));
|
|
32
28
|
if (result !== '["1","100","16","25","36","4","49","64","81","9"]') {
|
|
33
29
|
throw result;
|
|
34
30
|
}
|
|
@@ -60,9 +56,9 @@ const test = () => {
|
|
|
60
56
|
_map = set(_map)('f');
|
|
61
57
|
//
|
|
62
58
|
{
|
|
63
|
-
let _item =
|
|
59
|
+
let _item = next(values(_map));
|
|
64
60
|
while (_item !== null) {
|
|
65
|
-
_item =
|
|
61
|
+
_item = next(_item.tail);
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
type Array1
|
|
2
|
-
type Array2<T> = readonly [T, T];
|
|
1
|
+
import type { Array1, Array2 } from '../../array/module.f.ts';
|
|
3
2
|
export type Leaf1<T> = Array1<T>;
|
|
4
3
|
export type Leaf2<T> = Array2<T>;
|
|
5
4
|
export type Branch3<T> = readonly [TNode<T>, T, TNode<T>];
|
|
@@ -8,4 +7,3 @@ export type TNode<T> = Leaf1<T> | Leaf2<T> | Branch3<T> | Branch5<T>;
|
|
|
8
7
|
export type Tree<T> = TNode<T> | null;
|
|
9
8
|
export type Branch1<T> = readonly [TNode<T>];
|
|
10
9
|
export type Branch7<T> = readonly [...Branch5<T>, T, TNode<T>];
|
|
11
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type { RangeMap } from '../range_map/module.f.ts';
|
|
2
|
+
import type { SortedSet } from '../sorted_set/module.f.ts';
|
|
3
3
|
export type ByteSet = bigint;
|
|
4
4
|
type Byte = number;
|
|
5
5
|
export declare const has: (n: Byte) => (s: ByteSet) => boolean;
|
|
@@ -12,5 +12,5 @@ export declare const complement: (n: ByteSet) => ByteSet;
|
|
|
12
12
|
export declare const set: (_: number) => (b: ByteSet) => ByteSet;
|
|
13
13
|
export declare const setRange: (_: readonly [number, number]) => (b: ByteSet) => ByteSet;
|
|
14
14
|
export declare const unset: (n: Byte) => (s: ByteSet) => ByteSet;
|
|
15
|
-
export declare const toRangeMap: (n: ByteSet) => (s: string) => RangeMap
|
|
15
|
+
export declare const toRangeMap: (n: ByteSet) => (s: string) => RangeMap<SortedSet<string>>;
|
|
16
16
|
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { compose } from "../function/module.f.js";
|
|
2
|
-
import
|
|
3
|
-
import * as SortedSet from "../sorted_set/module.f.js";
|
|
4
|
-
import * as list from "../list/module.f.js";
|
|
5
|
-
const { reverse, countdown, flat, map } = list;
|
|
2
|
+
import { reverse, countdown, flat, map } from "../list/module.f.js";
|
|
6
3
|
export const has = n => s => ((s >> BigInt(n)) & 1n) === 1n;
|
|
7
4
|
// create a set
|
|
8
5
|
export const empty = 0n;
|
package/types/byte_set/test.f.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as _ from "./module.f.js";
|
|
2
|
-
import
|
|
3
|
-
const { every, countdown, map, toArray } = list;
|
|
2
|
+
import { every, countdown, map, toArray } from "../list/module.f.js";
|
|
4
3
|
import * as json from "../../json/module.f.js";
|
|
5
|
-
import
|
|
6
|
-
const { sort } = o;
|
|
4
|
+
import { sort } from "../object/module.f.js";
|
|
7
5
|
const stringify = json.stringify(sort);
|
|
8
6
|
export default {
|
|
9
7
|
has: [
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export type Index3 = Array.Index3;
|
|
3
|
-
export type Index5 = Array.Index5;
|
|
4
|
-
type Array2<T> = Array.Array2<T>;
|
|
1
|
+
import type { Index3, Index5, Array2 } from '../../array/module.f.ts';
|
|
5
2
|
export type Sign = -1 | 0 | 1;
|
|
6
3
|
export type Compare<T> = (_: T) => Sign;
|
|
7
4
|
export declare const index3: <T>(cmp: Compare<T>) => (value: T) => Index3;
|
|
8
5
|
export declare const index5: <T>(cmp: Compare<T>) => (v2: Array2<T>) => Index5;
|
|
9
6
|
export declare const unsafeCmp: <T>(a: T) => (b: T) => Sign;
|
|
10
|
-
export {};
|
|
@@ -13,7 +13,7 @@ export const flip = f => b => a => f(a)(b);
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates an `Fn` instance from a function, enabling chaining of transformations.
|
|
15
15
|
*/
|
|
16
|
-
export const fn = result => ({
|
|
16
|
+
export const fn = (result) => ({
|
|
17
17
|
result,
|
|
18
18
|
then: g => fn(compose(result)(g))
|
|
19
19
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Binary<A, B, R> = (a: A) => (b: B) => R;
|
|
1
|
+
export type Binary<A, B, R> = (a: A) => (b: B) => R;
|
|
2
2
|
export type Fold<I, O> = Binary<I, O, O>;
|
|
3
3
|
export declare const join: (separator: string) => Reduce<string>;
|
|
4
4
|
export declare const concat: Reduce<string>;
|
|
@@ -11,10 +11,9 @@ export type StateScan<I, S, O> = (prior: S) => (input: I) => readonly [O, S];
|
|
|
11
11
|
export declare const stateScanToScan: <I, S, O>(op: StateScan<I, S, O>) => (prior: S) => Scan<I, O>;
|
|
12
12
|
export declare const foldToScan: <I, O>(fold: Fold<I, O>) => (prior: O) => Scan<I, O>;
|
|
13
13
|
export type Reduce<T> = Fold<T, T>;
|
|
14
|
-
export declare const reduceToScan: <T>(
|
|
14
|
+
export declare const reduceToScan: <T>(op: Reduce<T>) => Scan<T, T>;
|
|
15
15
|
export declare const addition: Reduce<number>;
|
|
16
16
|
export declare const min: Reduce<number>;
|
|
17
17
|
export declare const max: Reduce<number>;
|
|
18
18
|
export declare const increment: (b: number) => number;
|
|
19
19
|
export declare const counter: () => (b: number) => number;
|
|
20
|
-
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export const join = separator => value => prior => `${prior}${separator}${value}`;
|
|
1
|
+
export const join = (separator) => value => prior => `${prior}${separator}${value}`;
|
|
2
2
|
export const concat = i => acc => `${acc}${i}`;
|
|
3
3
|
export const logicalNot = v => !v;
|
|
4
|
-
export const strictEqual = a => b => a === b;
|
|
5
|
-
export const stateScanToScan = op => prior => i => {
|
|
4
|
+
export const strictEqual = (a) => (b) => a === b;
|
|
5
|
+
export const stateScanToScan = (op) => (prior) => i => {
|
|
6
6
|
const [o, s] = op(prior)(i);
|
|
7
7
|
return [o, stateScanToScan(op)(s)];
|
|
8
8
|
};
|
|
9
|
-
export const foldToScan = fold => prior => i => {
|
|
9
|
+
export const foldToScan = (fold) => (prior) => i => {
|
|
10
10
|
const result = fold(i)(prior);
|
|
11
11
|
return [result, foldToScan(fold)(result)];
|
|
12
12
|
};
|
|
13
|
-
export const reduceToScan = op => init => [init, foldToScan(op)(init)];
|
|
13
|
+
export const reduceToScan = (op) => init => [init, foldToScan(op)(init)];
|
|
14
14
|
export const addition = a => b => a + b;
|
|
15
15
|
export const min = a => b => a < b ? a : b;
|
|
16
16
|
export const max = a => b => a > b ? a : b;
|
package/types/function/test.f.js
CHANGED
package/types/list/module.f.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type Concat<T> = {
|
|
|
13
13
|
readonly tail: List<T>;
|
|
14
14
|
};
|
|
15
15
|
export declare const concat: <T>(head: List<T>) => (tail: List<T>) => List<T>;
|
|
16
|
-
export declare const next: <T>(
|
|
16
|
+
export declare const next: <T>(head: List<T>) => Result<T>;
|
|
17
17
|
export declare const iterable: <T>(list: List<T>) => Iterable<T>;
|
|
18
18
|
export declare const toArray: <T>(list: List<T>) => readonly T[];
|
|
19
19
|
export declare const flat: <T>(list: List<List<T>>) => Thunk<T>;
|