for loops

This commit is contained in:
2026-06-22 20:11:18 +02:00
parent 380b5943b3
commit 27f42dd253
15 changed files with 1369 additions and 22 deletions
+70
View File
@@ -0,0 +1,70 @@
make_range :: func(calls @mut i32, end usize) int {
calls^ = calls^ + 1
return 0..end
}
global_range :: 0..1
main :: func() i32 {
total i32 = 0
first u8 = 254
last u8 = 255
for first..=last |value| {
_ = value
total = total + 1
}
signed_start i8 = -2
signed_end i8 = 1
for signed_start..signed_end |value| {
_ = value
total = total + 1
}
limit usize = 3
for 0..(limit + 1) |value| {
_ = value
total = total + 1
}
for 0..2 |outer| {
_ = outer
for 0..3 |inner| {
_ = inner
total = total + 1
}
}
for 5..2 |value| {
_ = value
total = total + 100
}
empty [0]i32 = []
for empty |value| {
_ = value
total = total + 100
}
pointed i32 = 3
pointers [1]@mut i32 = [&pointed]
for pointers |pointer| {
total = total + pointer^
}
calls i32 = 0
for make_range(&calls, 2) |value| {
_ = value
total = total + 1
}
for global_range |value| {
_ = value
total = total + 1
}
if calls == 1 {
total = total + 21
}
return total
}