Files
rose-ash/lib/ocaml/baseline
giles 1dd350d592
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
ocaml: phase 5.1 huffman.ml baseline (Huffman tree WPL = 224)
Classic CLRS Huffman code example. ADT:

  type tree = Leaf of int * char | Node of int * tree * tree

Build by repeatedly merging two lightest trees (sorted-list pq):

  let rec build_tree lst = match lst with
    | [t] -> t
    | a :: b :: rest ->
      let merged = Node (weight a + weight b, a, b) in
      build_tree (insert merged rest)

  weighted path length (= total Huffman bits):
    leaves {(5,a) (9,b) (12,c) (13,d) (16,e) (45,f)} -> 224

Tests sum-typed ADT with mixed arities, `function` keyword
pattern matching, recursive sorted insert, depth-counting recursion.

150 baseline programs total.
2026-05-10 06:21:06 +00:00
..