1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00
bobbylisp/example/factorial.hz

19 lines
348 B
Plaintext
Raw Normal View History

2022-04-01 03:15:36 -05:00
fun factorial (n: int) : int = do
2022-03-26 19:14:12 -05:00
match n with
2022-04-01 03:15:36 -05:00
| 0 -> return 1
| else return n * factorial(n - 1)
end
end
2022-03-18 22:03:43 -05:00
2022-04-01 03:15:36 -05:00
fun also_factorial (n: int) : int = do
if n == 0 then
return 1
else
return n * also_factorial(n - 1)
end
end
fun main : void = do
let result : int = factorial(5)
@write(result)
end