Recursion
Aquarius has only one loop control expression, for
expression.
for expression
expression2
will be calling when expression1
evaluates to true
, or it will jump to next stage of codes.
(for {expression1}:
{expression2}..
)
Optinally, for
expression contains an else
sub expression which will be calling while expression1
evalutes to false
.
(for {expression1}:
{expression2}..
else
{expression3}..
)
In scope of the for
expression, we can use two specific directives continue
and break
to do special stop. Their behavior are similar to that in other languages.
- break - exit from current loop immediately.
- continue - move from current cycle into next one.
(let i = 1)
(for (i < 10):
(if (i even?): break)
(i = (i + 1))
else
(puts: i) #i == 2#
)