Skip to content

Instantly share code, notes, and snippets.

@doublec
Created May 5, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doublec/133fb021e4c1afc4ec7a to your computer and use it in GitHub Desktop.
Save doublec/133fb021e4c1afc4ec7a to your computer and use it in GitHub Desktop.
ATS Fib
(* Comparing to http://www.reddit.com/r/rust/comments/34rszb/pony_type_and_memory_safe_language/cqy2wo7 *)
#include "share/atspre_staload.hats"
extern castfn u64(n: uint): uint64
fun fib(n: uint64): uint64 =
if n < u64(2u) then n else fib(n - u64(1u)) + fib(n - u64(2u))
implement main0(argc, argv) = let
val () = assertloc(argc = 2)
val n = g0string2uint(argv[1])
val result = fib(u64(n))
in
println! ("LANGUAGE ATS: ", result)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment