![]() |
|
Navigation |
Synopsis For loop.
Syntax
for ( Exp1 , Exp2 , ... , Expn ) Statement;
Description The for-statement executes
Statement for all possible combinations of values of the expressions Expi .
If one of the expressions is a boolean expression, we do try all its possible values.
By default, the value of a for statement is the empty list. In general, the value of a for statement consists of all values contributed by Append statements that are executed during the repeated execution of its body Statement.
Examples
rascal>import IO; ok rascal>for(int n <- [1 .. 5]) println("n = <n>"); n = 1 n = 2 n = 3 n = 4 list[void]: [] rascal>for(int n <- [1 .. 5]) append n * n; list[int]: [1,4,9,16] ![]() |