Created
May 5, 2015 11:29
-
-
Save doublec/133fb021e4c1afc4ec7a to your computer and use it in GitHub Desktop.
ATS Fib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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