diff --git a/lib/ocaml/baseline/expected.json b/lib/ocaml/baseline/expected.json index 12e627d0..201762dd 100644 --- a/lib/ocaml/baseline/expected.json +++ b/lib/ocaml/baseline/expected.json @@ -48,6 +48,7 @@ "memo_fib.ml": 75025, "mortgage.ml": 1073, "merge_sort.ml": 44, + "merge_two.ml": 441, "module_use.ml": 3, "newton_sqrt.ml": 1414, "mutable_record.ml": 10, diff --git a/lib/ocaml/baseline/merge_two.ml b/lib/ocaml/baseline/merge_two.ml new file mode 100644 index 00000000..314d9ef3 --- /dev/null +++ b/lib/ocaml/baseline/merge_two.ml @@ -0,0 +1,14 @@ +let rec merge xs ys = + match xs with + | [] -> ys + | x :: xs' -> + match ys with + | [] -> xs + | y :: ys' -> + if x <= y then x :: merge xs' (y :: ys') + else y :: merge (x :: xs') ys' + +;; + +let m = merge [1; 4; 7; 10] [2; 3; 5; 8; 9] in +List.fold_left (+) 0 m * List.length m diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index 5d58b014..f3ade729 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -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 — merge_two.ml baseline (merge two sorted + lists, length*sum = 9*49 = 441). Standard two-finger merge with + nested match-in-match. Used as a building block in merge_sort.ml + (iter 104) but called out as its own baseline here. Tests two-arg + recursion + nested match dispatch + classic comparison-based + merge. 85 baseline programs total. - 2026-05-09 Phase 5.1 — pow_mod.ml baseline (fast modular exponentiation, sum 738639). Recursive exponentiation by squaring: even exponent halves and squares, odd exponent multiplies by base