Files
rose-ash/lib/ocaml/baseline/expected.json
giles 554ef48c63
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
ocaml: phase 5.1 run_decode.ml baseline (RLE decode, expansion sum = 21)
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.
2026-05-09 16:47:56 +00:00

1.8 KiB