@fraczak/k 6.3.3 → 6.5.0
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/CHANGELOG.md +17 -0
- package/DOCS/CODECS.md +258 -0
- package/DOCS/DICTIONARY.md +1172 -0
- package/DOCS/KIR_SPECIALIZATION_DESIGN.md +51 -46
- package/DOCS/KIR_V1.md +221 -0
- package/DOCS/KVM_EXECUTION_MODEL.md +56 -19
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +2 -1
- package/DOCS/PROFILING_AND_TRACING.md +196 -0
- package/DOCS/REPL.md +61 -4
- package/DOCS/WEB_REPL_REQUIREMENTS.md +135 -0
- package/DOCS/dependency-graph.md +144 -0
- package/Examples/arithmetics.k +108 -82
- package/Examples/bnat.k +1 -1
- package/Examples/buda.k +44 -0
- package/Examples/ieee.k +300 -8671
- package/Examples/poly.k +67 -0
- package/README.md +68 -19
- package/Value.mjs +8 -2
- package/augmentation.mjs +9 -7
- package/backend-api.mjs +11 -2
- package/backends/arm64/README.md +104 -0
- package/backends/arm64/bin/k-arm64-compile.mjs +101 -0
- package/backends/arm64/bin/k-arm64-run.mjs +58 -0
- package/backends/arm64/bin/k-arm64.mjs +88 -0
- package/backends/arm64/scripts/run-tests.mjs +41 -0
- package/backends/arm64/src/arm64.mjs +229 -0
- package/backends/arm64/src/cli.mjs +155 -0
- package/backends/arm64/src/kvm2arm64.mjs +906 -0
- package/backends/arm64/src/runtime.c +728 -0
- package/backends/arm64/tests/integration.sh +112 -0
- package/backends/arm64/tests/test-arm64.mjs +240 -0
- package/backends/llvm/README.md +135 -0
- package/backends/llvm/bin/k-llvm-build.mjs +71 -0
- package/backends/llvm/bin/k-llvm-compile.mjs +68 -0
- package/backends/llvm/bin/k-llvm-jit.mjs +160 -0
- package/backends/llvm/bin/k-llvm-run.mjs +90 -0
- package/backends/llvm/runtime/krt.c +1508 -0
- package/backends/llvm/runtime/krt.h +109 -0
- package/backends/llvm/scripts/conformance.mjs +76 -0
- package/backends/llvm/scripts/run-tests.mjs +28 -0
- package/backends/llvm/src/executable.mjs +562 -0
- package/backends/llvm/src/kvm2llvm.mjs +998 -0
- package/backends/llvm/src/llvm.mjs +1092 -0
- package/backends/llvm/tests/composition-driver.c +22 -0
- package/backends/llvm/tests/identity-driver.c +27 -0
- package/backends/llvm/tests/integration.sh +153 -0
- package/backends/llvm/tests/perf-support.mjs +735 -0
- package/backends/llvm/tests/product-driver.c +23 -0
- package/backends/llvm/tests/projection-driver.c +19 -0
- package/backends/llvm/tests/relation-driver.c +29 -0
- package/backends/llvm/tests/test-llvm.mjs +240 -0
- package/backends/llvm/tests/union-driver.c +31 -0
- package/backends/llvm/tests/variant-driver.c +19 -0
- package/backends/llvm/tests/variant-projection-driver.c +21 -0
- package/backends/wasm/DOCS/USE-WEB-ASSEMBLY.md +233 -0
- package/backends/wasm/README.md +97 -0
- package/backends/wasm/TECHNICAL-DEBT.md +58 -0
- package/backends/wasm/bin/k-wasm-compile.mjs +50 -0
- package/backends/wasm/bin/k-wasm-run.mjs +140 -0
- package/backends/wasm/bin/k-wasm.mjs +49 -0
- package/backends/wasm/demo_ieee.mjs +319 -0
- package/backends/wasm/runtime.wat +475 -0
- package/backends/wasm/scripts/run-tests.mjs +41 -0
- package/backends/wasm/src/cli.mjs +133 -0
- package/backends/wasm/src/kvm2wasm.mjs +697 -0
- package/backends/wasm/src/wasm.mjs +1054 -0
- package/backends/wasm/tests/integration.sh +182 -0
- package/backends/wasm/tests/perf-support.mjs +336 -0
- package/backends/wasm/tests/test-wasm.mjs +625 -0
- package/browser/repl-browser.mjs +1584 -0
- package/browser/shims/assert.mjs +19 -0
- package/browser/shims/buffer.mjs +224 -0
- package/browser/shims/crypto.mjs +103 -0
- package/browser/shims/fs.mjs +159 -0
- package/browser/shims/os.mjs +17 -0
- package/browser/shims/path.mjs +54 -0
- package/browser/shims/process.mjs +44 -0
- package/browser/shims/readline.mjs +11 -0
- package/browser/shims/url.mjs +12 -0
- package/browser/vfs-data.mjs +19 -0
- package/codecs/README.md +3 -0
- package/codecs/runtime/show-value.mjs +12 -3
- package/conformance/helper-reuse/case.json +8 -0
- package/conformance/helper-reuse/expected.kv +1 -0
- package/conformance/helper-reuse/input.kv +1 -0
- package/conformance/helper-reuse/program.k +2 -0
- package/conformance/identity/case.json +8 -0
- package/conformance/identity/expected.kv +1 -0
- package/conformance/identity/input.kv +1 -0
- package/conformance/identity/program.k +1 -0
- package/conformance/product-projection/case.json +8 -0
- package/conformance/product-projection/expected.kv +1 -0
- package/conformance/product-projection/input.kv +1 -0
- package/conformance/product-projection/program.k +1 -0
- package/conformance/run.mjs +149 -0
- package/conformance/variant-construction/case.json +8 -0
- package/conformance/variant-construction/expected.kv +1 -0
- package/conformance/variant-construction/input.kv +1 -0
- package/conformance/variant-construction/program.k +1 -0
- package/harness/adapters/arm64.mjs +105 -0
- package/harness/adapters/kvm.mjs +144 -0
- package/harness/adapters/llvm.mjs +118 -0
- package/harness/adapters/native.mjs +77 -0
- package/harness/adapters/wasm.mjs +169 -0
- package/harness/backend.mjs +95 -0
- package/harness/cli.mjs +130 -0
- package/harness/format.mjs +95 -0
- package/harness/index.mjs +25 -0
- package/harness/persistent.mjs +121 -0
- package/harness/registry.mjs +44 -0
- package/harness/suite.mjs +257 -0
- package/harness/suites/poly.mjs +156 -0
- package/harness/trace.mjs +50 -0
- package/harness/util.mjs +92 -0
- package/intrinsics.mjs +41 -0
- package/kir.mjs +399 -0
- package/kvm.mjs +585 -81
- package/objects/README.md +37 -3
- package/objects/compile.mjs +15 -22
- package/objects/inspect.mjs +96 -0
- package/objects/validate.mjs +415 -0
- package/package.json +51 -19
- package/repl-codecs.mjs +105 -6
- package/repl.mjs +335 -49
- package/run.mjs +2 -7
- package/scripts/benchmark.mjs +406 -22
- package/scripts/build-repl-html.mjs +1784 -0
- package/scripts/perf-ieee.mjs +586 -0
- package/scripts/perf-int.mjs +531 -0
- package/scripts/perf-poly.mjs +945 -0
- package/scripts/render-benchmark.mjs +12 -8
- package/scripts/run-tests.mjs +6 -0
- package/tests/integration.sh +19 -2
- package/tests/test-arithmetics.mjs +54 -0
- package/tests/test-ieee-arithmetic.mjs +4 -0
- package/tests/test-kir.mjs +85 -0
- package/tests/test-kvm-polymorphic.mjs +278 -0
- package/tests/test-kvm.mjs +25 -6
- package/tests/test-poly.mjs +129 -0
- package/tests/test-repl-html.mjs +303 -0
- package/tests/test-repl.mjs +144 -1
- package/tests/test-validate-object.mjs +40 -0
- package/a.klib +0 -1
- package/a.kvm +0 -142676
- package/a.wasm +0 -0
- package/benchmark-results.html +0 -532
- package/benchmark-results.json +0 -480
- package/k-vscode/.vscode/launch.json +0 -14
- package/k-vscode/README.md +0 -75
- package/k-vscode/extension.js +0 -273
- package/k-vscode/language-configuration.json +0 -42
- package/k-vscode/package.json +0 -79
- package/k-vscode/snippets/k.json +0 -92
- package/k-vscode/syntaxes/k.tmLanguage.json +0 -599
- package/k-vscode/test/background-ranges.test.js +0 -50
- package/k-vscode/themes/k-contrast-color-theme.json +0 -104
- package/scripts/git-hooks/pre-commit +0 -10
package/Examples/arithmetics.k
CHANGED
|
@@ -15,10 +15,10 @@ cdr = list? /cons .cdr;
|
|
|
15
15
|
$ bits = < {} _, bits 0, bits 1 >;
|
|
16
16
|
|
|
17
17
|
0b = {} | _;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
-- |1 = | 1;
|
|
19
|
+
-- |0 = | 0;
|
|
20
20
|
|
|
21
|
-
0 = 0b
|
|
21
|
+
0 = 0b |0;
|
|
22
22
|
succ = {inv x, 0b y} _inc;
|
|
23
23
|
1 = 0 succ;
|
|
24
24
|
2 = 1 succ;
|
|
@@ -39,22 +39,33 @@ empty? = {empty /yes if, () then} .then;
|
|
|
39
39
|
concat = ${bits x, bits y} {.x inv x, .y y} concat_;
|
|
40
40
|
concat_ = ${bits x, bits y}
|
|
41
41
|
<
|
|
42
|
-
{.x
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
{.x empty? if, .y then} .then,
|
|
43
|
+
<
|
|
44
|
+
{.x /0 x, .y |0 y},
|
|
45
|
+
{.x /1 x, .y |1 y}
|
|
46
|
+
> concat_
|
|
45
47
|
>;
|
|
46
48
|
inv = {()x, 0b r} _inv;
|
|
47
|
-
_inv = ${bits x, bits r}
|
|
49
|
+
_inv = ${bits x, bits r}
|
|
50
|
+
<
|
|
51
|
+
{.x empty? if, .r then} .then,
|
|
52
|
+
<
|
|
53
|
+
{.x /0 x, .r |0 r},
|
|
54
|
+
{.x /1 x, .r |1 r}
|
|
55
|
+
> _inv
|
|
56
|
+
>;
|
|
48
57
|
|
|
49
58
|
inOrder = ${bits x, bits y} {.x inv x, .y inv y, yes inOrder} inOrder_;
|
|
50
59
|
inOrder_ = ${bits x, bits y, yes_no inOrder}
|
|
51
60
|
<
|
|
52
|
-
{.x
|
|
53
|
-
{.x /
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
{.x </0,/1> if1, .y /_ if2, .inOrder swap_yes_no then} .then,
|
|
62
|
+
{.x /_ if, .inOrder then} .then,
|
|
63
|
+
<
|
|
64
|
+
{.x /0 x, .y /0 y, .inOrder inOrder},
|
|
65
|
+
{.x /1 x, .y /1 y, .inOrder inOrder},
|
|
66
|
+
{.x /0 x, .y /1 y, .inOrder inOrder},
|
|
67
|
+
{.x /1 y, .y /0 x, .inOrder swap_yes_no inOrder}
|
|
68
|
+
> inOrder_
|
|
58
69
|
>;
|
|
59
70
|
|
|
60
71
|
GT = {inOrder /no if, () then} . then;
|
|
@@ -63,18 +74,21 @@ EQ = GT {.x y, .y x} GT;
|
|
|
63
74
|
|
|
64
75
|
toBitList = {inv x, nil r} _toBitList;
|
|
65
76
|
_toBitList = <
|
|
66
|
-
{.x empty? if, .r then
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
{.x empty? if, .r then}.then,
|
|
78
|
+
<
|
|
79
|
+
{.x /0 x, {0 car, .r cdr} cons r},
|
|
80
|
+
{.x /1 x, {1 car, .r cdr} cons r}
|
|
81
|
+
> _toBitList
|
|
69
82
|
>;
|
|
70
|
-
fromBitList =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
>
|
|
83
|
+
fromBitList = {() l, 0b r} _fromBitList inv $bits;
|
|
84
|
+
_fromBitList =
|
|
85
|
+
<
|
|
86
|
+
{.l nil? if, .r then} .then,
|
|
87
|
+
<
|
|
88
|
+
{.l car /0 if, {.l cdr l, .r |0 r} then} .then,
|
|
89
|
+
{.l car /1 if, {.l cdr l, .r |1 r} then} .then
|
|
90
|
+
> _fromBitList
|
|
91
|
+
>;
|
|
78
92
|
|
|
79
93
|
--------------------------------------
|
|
80
94
|
$ int = < bits '+', bits '-' >;
|
|
@@ -93,26 +107,26 @@ zero_int? = $int {/'+' /0 empty? if, () then} .then;
|
|
|
93
107
|
minus_one? = $int {/'-' /1 empty? if, () then} .then;
|
|
94
108
|
|
|
95
109
|
inc = $int <
|
|
96
|
-
/'+' {inv x, 0b y} _inc |'+',
|
|
110
|
+
/'+' {inv x, 0b y} _inc nat |'+',
|
|
97
111
|
minus_one? 0 int,
|
|
98
|
-
/'-' {inv x, 0b y} _dec |'-'
|
|
99
|
-
|
|
112
|
+
/'-' {inv x, 0b y} _dec nat |'-'
|
|
113
|
+
> $int;
|
|
100
114
|
|
|
101
115
|
_inc = ${bits x, bits y} <
|
|
102
|
-
{.x
|
|
103
|
-
{.x /
|
|
104
|
-
.y
|
|
116
|
+
{.x empty? if, .y |1 then} .then,
|
|
117
|
+
{.x /0 x, .y |1 y} concat_,
|
|
118
|
+
{.x /1 x, .y |0 y} _inc
|
|
105
119
|
>;
|
|
106
120
|
|
|
107
121
|
dec = $int <
|
|
108
122
|
zero_int? 1 |'-',
|
|
109
|
-
/'+' {inv x, 0b y} _dec |'+',
|
|
110
|
-
/'-' {inv x, 0b y} _inc |'-'
|
|
123
|
+
/'+' {inv x, 0b y} _dec nat |'+',
|
|
124
|
+
/'-' {inv x, 0b y} _inc nat |'-'
|
|
111
125
|
> $int;
|
|
112
126
|
|
|
113
127
|
_dec = ?{X x, X y, ...} <
|
|
114
|
-
{.x /1 x, .y
|
|
115
|
-
{.x /0 x, .y
|
|
128
|
+
{.x /1 x, .y |0 y} concat_,
|
|
129
|
+
{.x /0 x, .y |1 y} _dec
|
|
116
130
|
> ?X;
|
|
117
131
|
|
|
118
132
|
$carry = <{} 0, {} 1>;
|
|
@@ -139,45 +153,54 @@ swap_sign = <
|
|
|
139
153
|
minus = ${int x, int y}
|
|
140
154
|
{.x x, .y swap_sign y} plus;
|
|
141
155
|
|
|
142
|
-
_plus =
|
|
156
|
+
_plus = {.x x, .y y, .c c, 0b r} _plus_;
|
|
157
|
+
|
|
158
|
+
_plus_ =
|
|
143
159
|
-- least significant bit first addition with carry
|
|
144
|
-
${bits x, bits y, carry c}
|
|
160
|
+
${bits x, bits y, carry c, bits r}
|
|
145
161
|
<
|
|
146
|
-
{.x empty? if, .y empty? and,
|
|
147
|
-
{.x empty? if, .
|
|
162
|
+
{.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,
|
|
163
|
+
{.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,
|
|
164
|
+
{.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,
|
|
148
165
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
<
|
|
167
|
+
{.x y, .y empty? x, .c c, .r r},
|
|
168
|
+
{<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},
|
|
152
169
|
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
{.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},
|
|
171
|
+
{.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},
|
|
155
172
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
173
|
+
{.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},
|
|
174
|
+
{.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},
|
|
175
|
+
{.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},
|
|
176
|
+
{.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},
|
|
160
177
|
|
|
161
|
-
|
|
162
|
-
|
|
178
|
+
{.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},
|
|
179
|
+
{.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}
|
|
180
|
+
> _plus_
|
|
163
181
|
>
|
|
164
182
|
;
|
|
165
183
|
|
|
166
|
-
_minus =
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
_minus = {.x x, .y y, .c c, 0b r} _minus_;
|
|
185
|
+
|
|
186
|
+
_minus_ =
|
|
187
|
+
-- least significant bit first substraction with carry
|
|
188
|
+
${bits x, bits y, carry c, bits r}
|
|
169
189
|
<
|
|
170
|
-
{.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
{.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,
|
|
191
|
+
<
|
|
192
|
+
{.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},
|
|
193
|
+
{.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},
|
|
194
|
+
|
|
195
|
+
{.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},
|
|
196
|
+
{.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r},
|
|
197
|
+
{.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},
|
|
198
|
+
{.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},
|
|
199
|
+
{.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},
|
|
200
|
+
{.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},
|
|
201
|
+
{.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},
|
|
202
|
+
{.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}
|
|
203
|
+
> _minus_
|
|
181
204
|
>
|
|
182
205
|
;
|
|
183
206
|
|
|
@@ -209,23 +232,25 @@ _times =
|
|
|
209
232
|
${bits result, bits _x, bits y}
|
|
210
233
|
<
|
|
211
234
|
{ .y empty? if, .result then } .then,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
{
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
235
|
+
<
|
|
236
|
+
{
|
|
237
|
+
.result |0 result,
|
|
238
|
+
._x _x,
|
|
239
|
+
.y /0 y
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
{._x x, .result |0 y, c0 c } _plus result,
|
|
243
|
+
._x _x,
|
|
244
|
+
.y /1 y
|
|
245
|
+
}
|
|
246
|
+
> _times
|
|
222
247
|
>
|
|
223
248
|
;
|
|
224
249
|
|
|
225
250
|
|
|
226
251
|
mod =
|
|
227
252
|
${bits x, bits y}
|
|
228
|
-
_log!
|
|
253
|
+
-- _log!
|
|
229
254
|
<
|
|
230
255
|
-- if y > x then (x mod y) = x
|
|
231
256
|
{.y x, .x y} GT .y,
|
|
@@ -234,7 +259,7 @@ mod =
|
|
|
234
259
|
{
|
|
235
260
|
{
|
|
236
261
|
{.x int x, .y int y} minus /"+" x,
|
|
237
|
-
.y inv
|
|
262
|
+
.y inv |0 inv y
|
|
238
263
|
} mod x,
|
|
239
264
|
.y y
|
|
240
265
|
} mod
|
|
@@ -278,7 +303,7 @@ x_times_2_to_k =
|
|
|
278
303
|
|
|
279
304
|
_x_times_2_to_the_power_of_k = <
|
|
280
305
|
{.k zero_int? if, ._x then} .then,
|
|
281
|
-
{._x
|
|
306
|
+
{._x |0 _x, .k dec k} _x_times_2_to_the_power_of_k
|
|
282
307
|
>
|
|
283
308
|
;
|
|
284
309
|
|
|
@@ -324,17 +349,18 @@ lcm =
|
|
|
324
349
|
{{.x int x, .y int y} times x, gcd int y} div .div abs
|
|
325
350
|
;
|
|
326
351
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
352
|
+
factorial = {()n, 1 int acc} factorial_;
|
|
353
|
+
factorial_ = <
|
|
354
|
+
{.n zero_int? if, .acc then} .then,
|
|
355
|
+
{.n pos? dec n, {.n x, .acc y} times acc} factorial_
|
|
330
356
|
>;
|
|
331
357
|
|
|
332
358
|
fib_ =
|
|
333
359
|
<
|
|
360
|
+
{.n int zero_int? if, ."fib(n),fib(n.1)" then} .then,
|
|
334
361
|
{ .n int dec /"+" n,
|
|
335
362
|
."fib(n),fib(n.1)" {plus x, .x y} "fib(n),fib(n.1)"
|
|
336
|
-
} fib_
|
|
337
|
-
."fib(n),fib(n.1)"
|
|
363
|
+
} fib_
|
|
338
364
|
>
|
|
339
365
|
;
|
|
340
366
|
|
|
@@ -442,7 +468,7 @@ ratToString =
|
|
|
442
468
|
|
|
443
469
|
_rat! = $rat {
|
|
444
470
|
() carryOn,
|
|
445
|
-
ratToString
|
|
471
|
+
ratToString drop
|
|
446
472
|
} .carryOn;
|
|
447
473
|
|
|
448
474
|
|
package/Examples/bnat.k
CHANGED
package/Examples/buda.k
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// we will use arithmetics.k
|
|
2
|
+
|
|
3
|
+
nths = ?{$int n, LIST list}
|
|
4
|
+
<
|
|
5
|
+
{.n pos? dec n, .list cdr list } nths,
|
|
6
|
+
{.n zero_int? if, .list list? car then} .then
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
reverse = ? LIST list?
|
|
10
|
+
{nil ? LIST reversed, () list } _reverse;
|
|
11
|
+
|
|
12
|
+
_reverse = ?{ LIST reversed, LIST list}
|
|
13
|
+
<
|
|
14
|
+
{{.list car car, .reversed cdr} cons reversed, .list cdr list } _reverse,
|
|
15
|
+
.reversed
|
|
16
|
+
>
|
|
17
|
+
;
|
|
18
|
+
|
|
19
|
+
split = ? LIST
|
|
20
|
+
{ nil ? LIST odd, nil ? LIST even, reverse list } _split
|
|
21
|
+
;
|
|
22
|
+
|
|
23
|
+
_split = ? { LIST odd, LIST even, LIST list }
|
|
24
|
+
<
|
|
25
|
+
{
|
|
26
|
+
{.list car car, .odd cdr} cons odd,
|
|
27
|
+
.even even,
|
|
28
|
+
.list cdr list
|
|
29
|
+
} split_,
|
|
30
|
+
|
|
31
|
+
{.odd odd, .even even}
|
|
32
|
+
>
|
|
33
|
+
;
|
|
34
|
+
|
|
35
|
+
split_ = ? { LIST odd, LIST even, LIST list }
|
|
36
|
+
<
|
|
37
|
+
{
|
|
38
|
+
.odd odd,
|
|
39
|
+
{.list car car, .even cdr} cons even,
|
|
40
|
+
.list cdr list
|
|
41
|
+
} _split,
|
|
42
|
+
{.odd odd, .even even}
|
|
43
|
+
>
|
|
44
|
+
;
|