Loops/Do-while: Difference between revisions
Content added Content deleted
(Add lang example) |
|||
Line 2,031: | Line 2,031: | ||
x=0 |
x=0 |
||
\\ Do or Repeat |
\\ Do or Repeat |
||
Do |
|||
x++ |
|||
print x, |
|||
when x mod 6>0 |
|||
print |
|||
// or we can use Until x mod 6 = 0 |
|||
// and we can use block if we like it |
|||
x=0 |
|||
Do { |
Do { |
||
x++ |
x++ |
||
print x, |
|||
} |
} when x mod 6>0 |
||
print |
|||
x=0 |
x=0 |
||
{ |
{ |
||
Line 2,042: | Line 2,050: | ||
if x mod 6<>0 Then loop ' set loop flag of current block to true |
if x mod 6<>0 Then loop ' set loop flag of current block to true |
||
\\ when block end check Loop flag and if true execute block again |
\\ when block end check Loop flag and if true execute block again |
||
print x, |
|||
} |
} |
||
print |
|||
} |
} |
||
Checkit |
Checkit |
||
Line 2,050: | Line 2,059: | ||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
1 2 3 4 5 6 |
|||
1 |
|||
1 2 3 4 5 6 |
|||
2 |
|||
1 2 3 4 5 6 |
|||
3 |
|||
4 |
|||
5 |
|||
6 |
|||
1 |
|||
2 |
|||
3 |
|||
4 |
|||
5 |
|||
6 |
|||
</pre> |
</pre> |
||