[Shootout-list] ackermann.ocaml
Isaac Gouy
igouy2@yahoo.com
Thu, 6 Jan 2005 14:58:20 -0800 (PST)
Thanks!
We have this version as an alternative, so the interesting question is
why isn't it being measured?
> This version of ackermann.ocaml 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)
>
> best regards,
> Christoph Bauer
>
>
>
> --
> let () = let rec f a w i j = Printf.printf "%.20f\r" a; let a1 = a *.
> i /. j in
> if w then f a1 false (i +. 2.0) j else f a1 true i (j +. 2.0) in f
> 2.0 false 2.0 1.0
>
>
>
> _______________________________________________
> Shootout-list mailing list
> Shootout-list@lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/shootout-list
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com