[Shootout-list] ackermann.ocaml
chr_bauer at nexgo.de
chr_bauer at nexgo.de
Sun Apr 23 22:56:31 UTC 2006
Hi,
this version is a little bit faster, because it avoids a tuple construction in the
match.
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));;
let n = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 1 in
Printf.printf "Ack(3,%d): %d\n" n (ack 3 n)
kind regards,
Christoph Bauer
Arcor-DSL: die echte Flatrate für alle Bandbreiten. Jetzt ohne Einrichtungspreis
einsteigen oder wechseln. Arcor-DSL ist in vielen Anschlussgebieten verfügbar.
http://www.arcor.de/home/redir.php/emf-dsl-1
More information about the Shootout-list
mailing list