A for statement is used to loop over a list of values, executing statements each time.
forvariable
inlist
dostatement
forvariable
inlist
/* optional "do" here */statements
end
forkey
=variable
inlist
dostatement
forkey
=variable
inlist
/* optional "do" here */statements
end
In the for statement, variable
is set to a value from the list each time statements
are executed. When specified, key
is set to the key of that value in the list. If list
is actually not a list but a different type of value, the statements are executed only once with variable
set to that value.
The for statement may have an else clause and break and continue statements, just as the while statement.
Yewslip>
factorial = 1Yewslip>
n = 5Yewslip>
for i in [1:n+1]...>
factorial *= i...>
endYewslip>
print factorial120