ocaml: phase 5.1 hist.ml baseline (Hashtbl int histogram, total * max = 75)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s

Three small functions:

  hist xs       build a Hashtbl of count-by-value
  max_value h   Hashtbl.fold to find the max bin
  total h       Hashtbl.fold to sum all bins

For the 15-element list [1;2;3;1;4;5;1;2;6;7;1;8;9;1;0]:
  total      = 15
  max_value  =  5 (the number 1 appears 5 times)
  product    = 75

Companion to bag.ml (string keys) and frequency.ml (char keys) —
same Hashtbl.fold + Hashtbl.find_opt pattern, exercised on int
keys this time.

71 baseline programs total.
This commit is contained in:
2026-05-09 15:02:13 +00:00
parent 7f8bf5f455
commit 667dfcfd7c
3 changed files with 30 additions and 0 deletions

View File

@@ -31,6 +31,7 @@
"group_consec.ml": 53,
"hailstone.ml": 111,
"hanoi.ml": 1023,
"hist.ml": 75,
"fizzbuzz.ml": 57,
"flatten_tree.ml": 28,
"list_ops.ml": 30,