Loops (For While) - LieutenantTeaTM/BubbleTea GitHub Wiki

For

A for loop is defined by a range. The start and end have to be integer numeric for ranges to be defined. Syntax is as follows: for IDENTITIFER in INT .. INT {

Example:

for x in 0..10 {
    p!(x);
}
Output:
0
1
2
3
4
5
6
7
8
9

You can also use the by keyword to skip a specified amount of iterations. by is followed by an INT. Example:

for x in 0..10 by 5 {
    p!(x);
}
Output:
0
5

While

While loops repeat until a condition is met, they can be defined by while BOOLEAN CONDITION. Single word conditions such as true can work for infinite loops.

Example:

v &x: int -> 0;

while x <: 5 {
    x: x + 1;
    p!(x);
}
Output:
1
2
3
4
5