@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.
Files changed (157) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/DOCS/CODECS.md +258 -0
  3. package/DOCS/DICTIONARY.md +1172 -0
  4. package/DOCS/KIR_SPECIALIZATION_DESIGN.md +51 -46
  5. package/DOCS/KIR_V1.md +221 -0
  6. package/DOCS/KVM_EXECUTION_MODEL.md +56 -19
  7. package/DOCS/OBJECT_FILE_AND_PATTERN.md +2 -1
  8. package/DOCS/PROFILING_AND_TRACING.md +196 -0
  9. package/DOCS/REPL.md +61 -4
  10. package/DOCS/WEB_REPL_REQUIREMENTS.md +135 -0
  11. package/DOCS/dependency-graph.md +144 -0
  12. package/Examples/arithmetics.k +108 -82
  13. package/Examples/bnat.k +1 -1
  14. package/Examples/buda.k +44 -0
  15. package/Examples/ieee.k +300 -8671
  16. package/Examples/poly.k +67 -0
  17. package/README.md +68 -19
  18. package/Value.mjs +8 -2
  19. package/augmentation.mjs +9 -7
  20. package/backend-api.mjs +11 -2
  21. package/backends/arm64/README.md +104 -0
  22. package/backends/arm64/bin/k-arm64-compile.mjs +101 -0
  23. package/backends/arm64/bin/k-arm64-run.mjs +58 -0
  24. package/backends/arm64/bin/k-arm64.mjs +88 -0
  25. package/backends/arm64/scripts/run-tests.mjs +41 -0
  26. package/backends/arm64/src/arm64.mjs +229 -0
  27. package/backends/arm64/src/cli.mjs +155 -0
  28. package/backends/arm64/src/kvm2arm64.mjs +906 -0
  29. package/backends/arm64/src/runtime.c +728 -0
  30. package/backends/arm64/tests/integration.sh +112 -0
  31. package/backends/arm64/tests/test-arm64.mjs +240 -0
  32. package/backends/llvm/README.md +135 -0
  33. package/backends/llvm/bin/k-llvm-build.mjs +71 -0
  34. package/backends/llvm/bin/k-llvm-compile.mjs +68 -0
  35. package/backends/llvm/bin/k-llvm-jit.mjs +160 -0
  36. package/backends/llvm/bin/k-llvm-run.mjs +90 -0
  37. package/backends/llvm/runtime/krt.c +1508 -0
  38. package/backends/llvm/runtime/krt.h +109 -0
  39. package/backends/llvm/scripts/conformance.mjs +76 -0
  40. package/backends/llvm/scripts/run-tests.mjs +28 -0
  41. package/backends/llvm/src/executable.mjs +562 -0
  42. package/backends/llvm/src/kvm2llvm.mjs +998 -0
  43. package/backends/llvm/src/llvm.mjs +1092 -0
  44. package/backends/llvm/tests/composition-driver.c +22 -0
  45. package/backends/llvm/tests/identity-driver.c +27 -0
  46. package/backends/llvm/tests/integration.sh +153 -0
  47. package/backends/llvm/tests/perf-support.mjs +735 -0
  48. package/backends/llvm/tests/product-driver.c +23 -0
  49. package/backends/llvm/tests/projection-driver.c +19 -0
  50. package/backends/llvm/tests/relation-driver.c +29 -0
  51. package/backends/llvm/tests/test-llvm.mjs +240 -0
  52. package/backends/llvm/tests/union-driver.c +31 -0
  53. package/backends/llvm/tests/variant-driver.c +19 -0
  54. package/backends/llvm/tests/variant-projection-driver.c +21 -0
  55. package/backends/wasm/DOCS/USE-WEB-ASSEMBLY.md +233 -0
  56. package/backends/wasm/README.md +97 -0
  57. package/backends/wasm/TECHNICAL-DEBT.md +58 -0
  58. package/backends/wasm/bin/k-wasm-compile.mjs +50 -0
  59. package/backends/wasm/bin/k-wasm-run.mjs +140 -0
  60. package/backends/wasm/bin/k-wasm.mjs +49 -0
  61. package/backends/wasm/demo_ieee.mjs +319 -0
  62. package/backends/wasm/runtime.wat +475 -0
  63. package/backends/wasm/scripts/run-tests.mjs +41 -0
  64. package/backends/wasm/src/cli.mjs +133 -0
  65. package/backends/wasm/src/kvm2wasm.mjs +697 -0
  66. package/backends/wasm/src/wasm.mjs +1054 -0
  67. package/backends/wasm/tests/integration.sh +182 -0
  68. package/backends/wasm/tests/perf-support.mjs +336 -0
  69. package/backends/wasm/tests/test-wasm.mjs +625 -0
  70. package/browser/repl-browser.mjs +1584 -0
  71. package/browser/shims/assert.mjs +19 -0
  72. package/browser/shims/buffer.mjs +224 -0
  73. package/browser/shims/crypto.mjs +103 -0
  74. package/browser/shims/fs.mjs +159 -0
  75. package/browser/shims/os.mjs +17 -0
  76. package/browser/shims/path.mjs +54 -0
  77. package/browser/shims/process.mjs +44 -0
  78. package/browser/shims/readline.mjs +11 -0
  79. package/browser/shims/url.mjs +12 -0
  80. package/browser/vfs-data.mjs +19 -0
  81. package/codecs/README.md +3 -0
  82. package/codecs/runtime/show-value.mjs +12 -3
  83. package/conformance/helper-reuse/case.json +8 -0
  84. package/conformance/helper-reuse/expected.kv +1 -0
  85. package/conformance/helper-reuse/input.kv +1 -0
  86. package/conformance/helper-reuse/program.k +2 -0
  87. package/conformance/identity/case.json +8 -0
  88. package/conformance/identity/expected.kv +1 -0
  89. package/conformance/identity/input.kv +1 -0
  90. package/conformance/identity/program.k +1 -0
  91. package/conformance/product-projection/case.json +8 -0
  92. package/conformance/product-projection/expected.kv +1 -0
  93. package/conformance/product-projection/input.kv +1 -0
  94. package/conformance/product-projection/program.k +1 -0
  95. package/conformance/run.mjs +149 -0
  96. package/conformance/variant-construction/case.json +8 -0
  97. package/conformance/variant-construction/expected.kv +1 -0
  98. package/conformance/variant-construction/input.kv +1 -0
  99. package/conformance/variant-construction/program.k +1 -0
  100. package/harness/adapters/arm64.mjs +105 -0
  101. package/harness/adapters/kvm.mjs +144 -0
  102. package/harness/adapters/llvm.mjs +118 -0
  103. package/harness/adapters/native.mjs +77 -0
  104. package/harness/adapters/wasm.mjs +169 -0
  105. package/harness/backend.mjs +95 -0
  106. package/harness/cli.mjs +130 -0
  107. package/harness/format.mjs +95 -0
  108. package/harness/index.mjs +25 -0
  109. package/harness/persistent.mjs +121 -0
  110. package/harness/registry.mjs +44 -0
  111. package/harness/suite.mjs +257 -0
  112. package/harness/suites/poly.mjs +156 -0
  113. package/harness/trace.mjs +50 -0
  114. package/harness/util.mjs +92 -0
  115. package/intrinsics.mjs +41 -0
  116. package/kir.mjs +399 -0
  117. package/kvm.mjs +585 -81
  118. package/objects/README.md +37 -3
  119. package/objects/compile.mjs +15 -22
  120. package/objects/inspect.mjs +96 -0
  121. package/objects/validate.mjs +415 -0
  122. package/package.json +51 -19
  123. package/repl-codecs.mjs +105 -6
  124. package/repl.mjs +335 -49
  125. package/run.mjs +2 -7
  126. package/scripts/benchmark.mjs +406 -22
  127. package/scripts/build-repl-html.mjs +1784 -0
  128. package/scripts/perf-ieee.mjs +586 -0
  129. package/scripts/perf-int.mjs +531 -0
  130. package/scripts/perf-poly.mjs +945 -0
  131. package/scripts/render-benchmark.mjs +12 -8
  132. package/scripts/run-tests.mjs +6 -0
  133. package/tests/integration.sh +19 -2
  134. package/tests/test-arithmetics.mjs +54 -0
  135. package/tests/test-ieee-arithmetic.mjs +4 -0
  136. package/tests/test-kir.mjs +85 -0
  137. package/tests/test-kvm-polymorphic.mjs +278 -0
  138. package/tests/test-kvm.mjs +25 -6
  139. package/tests/test-poly.mjs +129 -0
  140. package/tests/test-repl-html.mjs +303 -0
  141. package/tests/test-repl.mjs +144 -1
  142. package/tests/test-validate-object.mjs +40 -0
  143. package/a.klib +0 -1
  144. package/a.kvm +0 -142676
  145. package/a.wasm +0 -0
  146. package/benchmark-results.html +0 -532
  147. package/benchmark-results.json +0 -480
  148. package/k-vscode/.vscode/launch.json +0 -14
  149. package/k-vscode/README.md +0 -75
  150. package/k-vscode/extension.js +0 -273
  151. package/k-vscode/language-configuration.json +0 -42
  152. package/k-vscode/package.json +0 -79
  153. package/k-vscode/snippets/k.json +0 -92
  154. package/k-vscode/syntaxes/k.tmLanguage.json +0 -599
  155. package/k-vscode/test/background-ranges.test.js +0 -50
  156. package/k-vscode/themes/k-contrast-color-theme.json +0 -104
  157. package/scripts/git-hooks/pre-commit +0 -10
@@ -15,10 +15,10 @@ cdr = list? /cons .cdr;
15
15
  $ bits = < {} _, bits 0, bits 1 >;
16
16
 
17
17
  0b = {} | _;
18
- 1_ = | 1;
19
- 0_ = | 0;
18
+ -- |1 = | 1;
19
+ -- |0 = | 0;
20
20
 
21
- 0 = 0b 0_;
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 /0 x, .y 0_ y} concat_,
43
- {.x /1 x, .y 1_ y} concat_,
44
- .y
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} < {.x /0 x, .r 0_ r} _inv, {.x /1 x, .r 1_ r} _inv, .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 /0 x, .y /0 y, .inOrder inOrder} inOrder_,
53
- {.x /1 x, .y /1 y, .inOrder inOrder} inOrder_,
54
- {.x /0 x, .y /1 y, .inOrder inOrder} inOrder_,
55
- {.x /1 y, .y /0 x, .inOrder swap_yes_no inOrder} inOrder_,
56
- {.x </0,/1> if, .inOrder swap_yes_no then} .then,
57
- .inOrder
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 }.then,
67
- {.x /0 x, {0 car, .r cdr} cons r} _toBitList,
68
- {.x /1 x, {1 car, .r cdr} cons r} _toBitList
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
- cdr <
73
- {car /0 if, cdr fromBitList 0_ then} .then,
74
- {car /1 if, cdr fromBitList 1_ then} .then
75
- >,
76
- 0b
77
- > $bits;
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 /0 x, .y 1_ y} concat_,
103
- {.x /1 x, .y 0_ y} _inc,
104
- .y 1_
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 0_ y} concat_,
115
- {.x /0 x, .y 1_ y} _dec
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, <.c/0 0, 1> then} .then,
147
- {.x empty? if, .c/0 and, .y then} .then,
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
- {.x y, .y empty? x, .c c} _plus,
150
- {<.c/0 0, 1> x,
151
- .y y, .x empty? c0 c} _plus,
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
- {.x /0 x, .y /0 y, .c/0 c0 c} _plus 0_,
154
- {.x /0 x, .y /0 y, .c/1 c0 c} _plus 1_,
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
- {.x /0 x, .y /1 y, .c/0 c0 c} _plus 1_,
157
- {.x /0 x, .y /1 y, .c/1 c1 c} _plus 0_,
158
- {.x /1 x, .y /0 y, .c/0 c0 c} _plus 1_,
159
- {.x /1 x, .y /0 y, .c/1 c1 c} _plus 0_,
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
- {.x /1 x, .y /1 y, .c/0 c1 c} _plus 0_,
162
- {.x /1 x, .y /1 y, .c/1 c1 c} _plus 1_
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
- -- least significat bit first substraction with carry
168
- ${bits x, bits y, carry c}
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
- {.x then, .y empty? if, .c/0 and} .then,
171
- {.x/1 then, .y empty? if, .c/1 and} .then 0_,
172
- {.x/0 x, .y empty? y, .c/1 c1 c} _minus 1_,
173
- {.x/0 x, .y/0 y, .c/0 c0 c} _minus 0_,
174
- {.x/0 x, .y/0 y, .c/1 c1 c} _minus 1_,
175
- {.x/0 x, .y/1 y, .c/0 c1 c} _minus 1_,
176
- {.x/0 x, .y/1 y, .c/1 c1 c} _minus 0_,
177
- {.x/1 x, .y/0 y, .c/0 c0 c} _minus 1_,
178
- {.x/1 x, .y/0 y, .c/1 c0 c} _minus 0_,
179
- {.x/1 x, .y/1 y, .c/0 c0 c} _minus 0_,
180
- {.x/1 x, .y/1 y, .c/1 c1 c} _minus 1_
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
- .result 0_ result,
214
- ._x _x,
215
- .y /0 y
216
- } _times,
217
- {
218
- {._x x, .result 0_ y, c0 c } _plus result,
219
- ._x _x,
220
- .y /1 y
221
- } _times
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 0_ inv y
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 0_ _x, .k dec k} _x_times_2_to_the_power_of_k
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
- factorial = <
328
- zero_int? 1 int,
329
- /"+" int {dec factorial x, () y} times
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 _log! drop
471
+ ratToString drop
446
472
  } .carryOn;
447
473
 
448
474
 
package/Examples/bnat.k CHANGED
@@ -288,4 +288,4 @@ _sqrt =
288
288
 
289
289
  --------------------
290
290
 
291
- _log! lcm
291
+ lcm
@@ -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
+ ;