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

@ -70,14 +70,14 @@ main() {
if x == 0 {
sys.exit(0)
}
sys.exit(1)
}
inc(x) {
inc(x Int) -> Int {
return x + 1
}
dec(x) {
dec(x Int) -> Int {
return x - 1
}

View File

@ -2,6 +2,6 @@ main() {
assert f(1) + f(2) + f(3) == 9
}
f(x) {
f(x Int) -> Int {
return x + 1
}

View File

@ -12,6 +12,6 @@ main() {
}
}
f(x) {
f(x Int) -> Int {
return x
}

View File

@ -4,10 +4,10 @@ main() {
assert result == 10
}
div(x, y) {
div(x Int, y Int) -> Int {
return x / y
}
div10(x) {
div10(x Int) -> Int {
return x / 10
}

View File

@ -5,6 +5,6 @@ main() {
assert neg(256) == -256
}
neg(x) {
neg(x Int) -> Int {
return -x
}

View File

@ -2,6 +2,6 @@ main() {
assert f(f(f(1))) == 4
}
f(x) {
f(x Int) -> Int {
return x + 1
}

View File

@ -2,7 +2,7 @@ main() {
f(10)
}
f(new) {
f(new Int) {
old := new
new -= 1
assert new != old

View File

@ -2,11 +2,11 @@ main() {
assert f(1, 2, 3) == 21
}
f(x, y, z) {
f(x Int, y Int, z Int) -> Int {
w := g(4, 5, 6)
return x + y + z + w
}
g(x, y, z) {
g(x Int, y Int, z Int) -> Int {
return x + y + z
}

View File

@ -2,11 +2,11 @@ main() {
f(1, 2, 3, 4, 5, 6)
}
f(a, b, c, d, e, f) {
return g(f, e, d, c, b, a)
f(a Int, b Int, c Int, d Int, e Int, f Int) {
g(f, e, d, c, b, a)
}
g(a, b, c, d, e, f) {
g(a Int, b Int, c Int, d Int, e Int, f Int) {
assert a == 6
assert b == 5
assert c == 4

View File

@ -2,11 +2,11 @@ main() {
assert f(1) == 3
}
f(x) {
f(x Int) -> Int {
y := g()
return x + y
}
g() {
g() -> Int {
return 2
}

View File

@ -15,14 +15,14 @@ main() {
assert i == 1 + 4
}
reverse2(a, b) {
reverse2(a Int, b Int) -> (Int, Int) {
return b, a
}
reverse3(a, b, c) {
reverse3(a Int, b Int, c Int) -> (Int, Int, Int) {
return c, b, a
}
mix4(a, b, c, d) {
mix4(a Int, b Int, c Int, d Int) -> (Int, Int, Int, Int) {
return d + a, c + b, b + c, a + d
}

View File

@ -2,10 +2,10 @@ main() {
assert f(2) == 6
}
f(x) {
f(x Int) -> Int {
return x + 1 + g(x)
}
g(x) {
g(x Int) -> Int {
return x + 1
}

View File

@ -2,6 +2,6 @@ main() {
assert f(1) == 3
}
f(x) {
f(x Int) -> Int {
return x + 1 + x
}

View File

@ -2,6 +2,6 @@ main() {
assert f(2, 3) == 25
}
f(x, y) {
f(x Int, y Int) -> Int {
return (x + y) * (x + y)
}