ocaml: phase 5.1 ackermann.ml baseline (ack(3, 4) = 125)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Classic Ackermann function:
let rec ack m n =
if m = 0 then n + 1
else if n = 0 then ack (m - 1) 1
else ack (m - 1) (ack m (n - 1))
ack(3, 4) = 125, expanding to ~6700 evaluator frames — a useful
stress test of the call stack and control transfer. Real OCaml
evaluates this in milliseconds; ours takes ~2 minutes on a
contended host but completes correctly.
40 baseline programs total.
This commit is contained in:
8
lib/ocaml/baseline/ackermann.ml
Normal file
8
lib/ocaml/baseline/ackermann.ml
Normal file
@@ -0,0 +1,8 @@
|
||||
let rec ack m n =
|
||||
if m = 0 then n + 1
|
||||
else if n = 0 then ack (m - 1) 1
|
||||
else ack (m - 1) (ack m (n - 1))
|
||||
|
||||
;;
|
||||
|
||||
ack 3 4
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"ackermann.ml": 125,
|
||||
"anagrams.ml": 3,
|
||||
"bag.ml": 3,
|
||||
"balance.ml": 3,
|
||||
|
||||
Reference in New Issue
Block a user