// range(start..end) generates an array of consecutive integers from start to end (inclusive)

// basic iteration
def total as integer(0)
for n in range(1..10) (
  total += n
)
assert(total == 55)
print("sum 1..10 = {{total}}")

// assign to array variable
def nums as array
nums = range(1..5)
assert(nums.len() == 5)
assert(nums.get(0) == 1)
assert(nums.get(4) == 5)
print("nums = {{nums}}")

// range with variable bounds
def start as integer(3)
def stop  as integer(7)
def slice as array
slice = range(start..stop)
assert(slice.len() == 5)
print("slice = {{slice}}")

// combine with break()
def first_even as integer(0)
for n in range(1..100) (
  if n % 2 == 0 (
    first_even = n
    break()
  )
)
assert(first_even == 2)
print("first even in 1..100 = {{first_even}}")
