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.
9 lines
123 B
OCaml
9 lines
123 B
OCaml
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
|