top of page

Loops

A while loop simply executes a statement as long as the given condition is satisfied.

​

while condition ) (

statement

)

​

A for-loop is more versatile and can be used for a variety of purposes.

​

It can be used to simply repeat a block of code a set number of times

​

for 3 (

print "Hello World"

)

​

It can be used to iterate through the items of a list or tuple 

​

for x in [1, 2, 3] (

print x

)

​

It can also be used as a traditional for-loop

​

for ( initialisation; condition; afterthought ) (

statement

)

​

It can be used to iterate through multiple lists at the same time

​

for {x in (1..10), y in (1..10)} (

print {x, y}

)

​

A do-loop executes the statement before starting the loop

​

do (

statement

) while ( condition )

​

and similarly with the for-loop.

​

do (

statement

) for n

​

The keywords break and continue can be used as usual along with two new keyword stop and skip. stop can be used to break multiple loops at once. skip can be used to "continue" over the loop multiple number of times.

​

​

​

bottom of page