Implemented loop iterators

This commit is contained in:
2025-02-19 17:52:15 +01:00
parent 1bc845e6f0
commit 7922cff7ba
17 changed files with 147 additions and 35 deletions

View File

@ -1,23 +0,0 @@
import mem
main() {
a := mem.alloc(4)
i := 0
a[i] = i * 2
i += 1
a[i] = i * 2
i += 1
a[i] = i * 2
i += 1
a[i] = i * 2
i = 0
assert a[i] == i * 2
i += 1
assert a[i] == i * 2
i += 1
assert a[i] == i * 2
i += 1
assert a[i] == i * 2
}

View File

@ -0,0 +1,10 @@
import mem
main() {
a := mem.alloc(4)
loop i := 0..4 {
a[i] = i * 2
assert a[i] == i * 2
}
}

View File

@ -0,0 +1,6 @@
main() {
loop i := 0..10 {
assert i >= 0
assert i < 10
}
}