Yard/test.yard

31 lines
519 B
Plaintext

@feature(io, conv)
@version(100)
@author(Sven Vogel)
-- compute the factorial
-- in a recursive and functional way
fac(x:int) = int {
despite x != 1 {
yield 1;
}
yield fac(x - 1) * x
}
number = rat 12.0 # this is a function without arguments and a braceless body
// main function
main = int {
result = fac(to_int(number));
println("The Factorial of " .. number() .. " is: " .. result);
x:int = 0;
until x > 9 {
println("" .. x);
x = x + 1
}
yield 0;
}