diff --git a/lib/ocaml/baseline/adler32.ml b/lib/ocaml/baseline/adler32.ml new file mode 100644 index 00000000..aa802806 --- /dev/null +++ b/lib/ocaml/baseline/adler32.ml @@ -0,0 +1,13 @@ +let adler32 s = + let a = ref 1 in + let b = ref 0 in + let m = 65521 in + for i = 0 to String.length s - 1 do + a := (!a + Char.code s.[i]) mod m; + b := (!b + !a) mod m + done; + !b * 65536 + !a + +;; + +adler32 "Wikipedia" diff --git a/lib/ocaml/baseline/expected.json b/lib/ocaml/baseline/expected.json index 019e45a1..4262f1f0 100644 --- a/lib/ocaml/baseline/expected.json +++ b/lib/ocaml/baseline/expected.json @@ -1,5 +1,6 @@ { "ackermann.ml": 125, + "adler32.ml": 300286872, "anagram_check.ml": 2, "anagrams.ml": 3, "atm.ml": 120, diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index 0632af61..01e2f3a0 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -407,6 +407,11 @@ _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 — adler32.ml baseline (Adler-32 checksum of + "Wikipedia" = 300286872 = 0x11E60398). Two running sums modulo + 65521; final checksum is `b * 65536 + a`. Used by zlib for stream + integrity. Tests for-loop accumulating two refs, modular + arithmetic, and Char.code on s.[i]. 96 baseline programs total. - 2026-05-09 Phase 5.1 — gray_code.ml baseline (4-bit binary reflected Gray code, sum 120 + length 16 = 136). Single-formula generation: `gray[i] = i lxor (i lsr 1)`. Outputs a permutation of