Loop structures: Difference between revisions
Content added Content deleted
(→Jinja) |
(→SIMPOL) |
||
Line 900: | Line 900: | ||
end while field =@= table.firstfield |
end while field =@= table.firstfield |
||
end function fieldnames</lang> |
end function fieldnames</lang> |
||
=={{header|Sing}}== |
|||
<lang Sing>fn loops() void |
|||
{ |
|||
// while: the condition must be strictly of boolean type |
|||
var idx = 0; |
|||
while (idx < 10) { |
|||
++idx; |
|||
} |
|||
// for in an integer range, the last value is excluded |
|||
// it is local to the loop and must not be previously declared |
|||
for (it in 0 : 10) { |
|||
} |
|||
// reverse direction |
|||
for (it in 10 : 0) { |
|||
} |
|||
// configurable step. The loop stops when it >= the final value |
|||
for (it in 0 : 100 step 3) { |
|||
} |
|||
// with an auxiliary counter. The counter start always at 0 and increments by one at each iteration |
|||
for (counter, it in 3450 : 100 step -22) { |
|||
} |
|||
// value assumes in turn all the values from array |
|||
var array [*]i32 = {0, 10, 100, 1000}; |
|||
for (value in array) { |
|||
} |
|||
// as before with auxiliary counter |
|||
for (counter, value in array) { |
|||
} |
|||
}</lang> |
|||
==[[SNUSP]]== |
==[[SNUSP]]== |