BER Programming Language - Loops

Loops let you repeat code multiple times. BER supports a for loop that runs a block of code for a set number of times.

Basic For Loop

for i is 1 to 5
  board:(i)
end

Explanation: This loop prints numbers 1 to 5. The syntax is for <variable> is <start> to <end> followed by the loop body, closed with end.

Using Loops with Tables

table names is ["Bernardo", "Ana", "Luca"]

for i is 1 to 3
  board:(names(i))
end

This example prints each name in the names table.

Tip: Always use end to close loops to avoid syntax errors.