Added types

This commit is contained in:
2024-08-05 18:47:24 +02:00
parent cd1119add2
commit 83661c5e7a
33 changed files with 113 additions and 92 deletions

View File

@ -5,7 +5,7 @@ main() {
collatz(12)
}
collatz(x) {
collatz(x Int) {
loop {
if x & 1 == 0 {
x /= 2

View File

@ -4,7 +4,7 @@ main() {
log.number(factorial(5))
}
factorial(x) {
factorial(x Int) -> Int {
if x <= 1 {
return 1
}

View File

@ -4,7 +4,7 @@ main() {
log.number(fibonacci(10))
}
fibonacci(x) {
fibonacci(x Int) -> Int {
if x <= 1 {
return x
}

View File

@ -5,7 +5,7 @@ main() {
fizzbuzz(15)
}
fizzbuzz(n) {
fizzbuzz(n Int) {
x := 1
loop {
@ -26,6 +26,6 @@ fizzbuzz(n) {
}
}
print(address, length) {
print(address Pointer, length Int) {
sys.write(1, address, length)
}

View File

@ -4,7 +4,7 @@ main() {
log.number(gcd(1071, 462))
}
gcd(a, b) {
gcd(a Int, b Int) -> Int {
loop {
switch {
a == b { return a }

View File

@ -4,6 +4,6 @@ main() {
print("Hello\n", 6)
}
print(address, length) {
print(address Pointer, length Int) {
sys.write(1, address, length)
}

View File

@ -22,7 +22,7 @@ main() {
}
}
isPrime(x) {
isPrime(x Int) -> Int {
if x == 2 {
return 1
}