ocaml: phase 5.1 adler32.ml baseline (Adler-32 of 'Wikipedia' = 300286872 = 0x11E60398)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s

Two running sums modulo 65521:

  a = (1 + sum of bytes)            mod 65521
  b = sum of running 'a' values     mod 65521
  checksum = b * 65536 + a

  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

For 'Wikipedia': 0x11E60398 = 300286872 (the canonical test value).

Tests for-loop accumulating two refs together, modular arithmetic,
and Char.code on s.[i].

96 baseline programs total.
This commit is contained in:
2026-05-09 19:18:01 +00:00
parent 37a514d566
commit 810f61a1c1
3 changed files with 19 additions and 0 deletions

View File

@@ -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"

View File

@@ -1,5 +1,6 @@
{
"ackermann.ml": 125,
"adler32.ml": 300286872,
"anagram_check.ml": 2,
"anagrams.ml": 3,
"atm.ml": 120,

View File

@@ -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