ocaml: phase 5.1 gcd_lcm.ml baseline (Euclidean gcd + lcm, 12+12+36 = 60)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s
Two-line baseline: let rec gcd a b = if b = 0 then a else gcd b (a mod b) let lcm a b = a * b / gcd a b gcd 36 48 = 12 lcm 4 6 = 12 lcm 12 18 = 36 sum = 60 Tests mod arithmetic and the integer-division fix from iteration 94 (without truncate-toward-zero, 'lcm 4 6 = 4 * 6 / 2 = 12.0' rather than the expected 12). 54 baseline programs total.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
"factorial.ml": 3628800,
|
"factorial.ml": 3628800,
|
||||||
"fraction.ml": 7,
|
"fraction.ml": 7,
|
||||||
"frequency.ml": 5,
|
"frequency.ml": 5,
|
||||||
|
"gcd_lcm.ml": 60,
|
||||||
"grep_count.ml": 3,
|
"grep_count.ml": 3,
|
||||||
"hanoi.ml": 1023,
|
"hanoi.ml": 1023,
|
||||||
"fizzbuzz.ml": 57,
|
"fizzbuzz.ml": 57,
|
||||||
|
|||||||
6
lib/ocaml/baseline/gcd_lcm.ml
Normal file
6
lib/ocaml/baseline/gcd_lcm.ml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
|
||||||
|
|
||||||
|
let lcm a b = a * b / gcd a b
|
||||||
|
;;
|
||||||
|
|
||||||
|
gcd 36 48 + lcm 4 6 + lcm 12 18
|
||||||
@@ -407,6 +407,12 @@ _Newest first._
|
|||||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||||
recursive match, List.append, List.fold_left.
|
recursive match, List.append, List.fold_left.
|
||||||
|
- 2026-05-09 Phase 5.1 — gcd_lcm.ml baseline (Euclidean gcd + lcm,
|
||||||
|
12 + 12 + 36 = 60). Two-line baseline: `let rec gcd a b = if b = 0
|
||||||
|
then a else gcd b (a mod b)` + `let lcm a b = a * b / gcd a b`.
|
||||||
|
Tests `mod` arithmetic and the integer-division fix from
|
||||||
|
iteration 94 (without truncate-toward-zero, lcm 4 6 = 4*6 / 2 =
|
||||||
|
12.0 not 12). 54 baseline programs total.
|
||||||
- 2026-05-09 Phase 5.1 — zip_unzip.ml baseline (list zip/unzip
|
- 2026-05-09 Phase 5.1 — zip_unzip.ml baseline (list zip/unzip
|
||||||
round-trip, sum-product = 1000). zip walks both lists in lockstep
|
round-trip, sum-product = 1000). zip walks both lists in lockstep
|
||||||
truncating at the shorter; unzip uses tuple-pattern destructuring
|
truncating at the shorter; unzip uses tuple-pattern destructuring
|
||||||
|
|||||||
Reference in New Issue
Block a user