ocaml: phase 5.1 run_decode.ml baseline (RLE decode, expansion sum = 21)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Inverse of run_length.ml from iteration 130. Takes a list of
(value, count) tuples and expands:
let rec rle_decode pairs =
match pairs with
| [] -> []
| (x, n) :: rest ->
let rec rep k = if k = 0 then [] else x :: rep (k - 1) in
rep n @ rle_decode rest
rle_decode [(1,3); (2,2); (3,4); (1,2)]
= [1;1;1; 2;2; 3;3;3;3; 1;1]
sum = 3 + 4 + 12 + 2 = 21.
Tests tuple-cons pattern, inner-let recursion, list concat (@), and
the 'List.fold_left (+) 0' invariant on encoding round-trips.
81 baseline programs total.
This commit is contained in:
@@ -407,6 +407,12 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-09 Phase 5.1 — run_decode.ml baseline (RLE decode, sum of
|
||||
expansion = 21). Inverse of run_length.ml: takes a list of
|
||||
`(value, count)` tuples, expands each pair via inner `rep` helper,
|
||||
and concatenates with `@`. Companion to run_length encoding from
|
||||
iteration 130. `[(1,3);(2,2);(3,4);(1,2)]` expands to
|
||||
[1;1;1;2;2;3;3;3;3;1;1] (sum = 21). 81 baseline programs total.
|
||||
- 2026-05-09 Phase 5.1 — peano.ml baseline (Peano arithmetic, 5*6 =
|
||||
30). Defines `type peano = Zero | Succ of peano` and four
|
||||
recursive functions: to_int, from_int, plus, mul. Multiplication
|
||||
|
||||
Reference in New Issue
Block a user