samples: add Terra samples

source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
Bayu Aldi Yansyah
2016-01-28 11:22:27 +07:00
parent e32a837fb2
commit 9b8b39f444
370 changed files with 11921 additions and 0 deletions

27
samples/Terra/fib2.t Normal file
View File

@@ -0,0 +1,27 @@
local test = require("test")
local Num = int
terra fib(a : Num) : Num
if a == 0 then
return 1
elseif a == 1 then
return 1
else
return fib(a - 1) + fib(a - 2)
end
end
function fib2(a)
if a == 0 then
return 1
elseif a == 1 then
return 1
else
return fib2(a - 1) + fib2(a - 2)
end
end
for i = 0,10 do
print(fib(i))
test.eq(fib(i),fib2(i))
end