ocaml: phase 5.1 partition.ml baseline (stable partition, evens*100 + odds = 3025)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s

Two ref lists accumulating in reverse, then List.rev'd — preserves
original order:

  let partition pred xs =
    let yes = ref [] in
    let no = ref [] in
    List.iter (fun x ->
      if pred x then yes := x :: !yes
      else no := x :: !no
    ) xs;
    (List.rev !yes, List.rev !no)

  partition (fun x -> x mod 2 = 0) [1..10]
  -> ([2;4;6;8;10], [1;3;5;7;9])

  evens sum * 100 + odds sum = 30 * 100 + 25 = 3025

Tests higher-order predicate, tuple return, and iter-98 let-tuple
destructuring on the call site.

108 baseline programs total.
This commit is contained in:
2026-05-09 21:26:31 +00:00
parent c16a8f2d53
commit cecde8733a
3 changed files with 21 additions and 0 deletions

View File

@@ -74,6 +74,7 @@
"option_match.ml": 5,
"palindrome.ml": 4,
"paren_depth.ml": 7,
"partition.ml": 3025,
"pancake_sort.ml": 910,
"pascal.ml": 252,
"peano.ml": 30,