Finish up old example that shows off basic expressions and funcalls

The VM now supports the various int comparison methods. An example of a
"pow" method is given to show off recursion, which means we're now
TURING COMPLETE!

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-11-09 16:50:16 -08:00
parent 357aad5306
commit c6212f5597
5 changed files with 165 additions and 28 deletions

View File

@@ -1,13 +1,15 @@
# pow = fn (n, p) {
# if p == 0 {
# 1
# } else {
# n * pow(n, p - 1)
# }
# }
pow = fn (n, p) {
if p <= 0 {
return 1
} el {
return n * pow(n, p - 1)
}
}
kilo = pow(2, 10)
mega = pow(2, 20)
giga = pow(2, 30)
tera = pow(2, 40)
peta = pow(2, 50)
println(kilo)
println(mega)
println(giga)