Loops/Do-while: Difference between revisions
PascalABC.NET
m (→{{header|C3}}) |
(PascalABC.NET) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1,183:
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">▼
value = 0
repeat
value += 1
print value
until
.
</syntaxhighlight>
Line 2,325 ⟶ 2,324:
inc val
echo val</syntaxhighlight>
mut n = 0
$n += 1
print $n
}
=={{header|Oberon-2}}==
Line 2,467 ⟶ 2,476:
until i mod 6 = 0
end.</syntaxhighlight>
=={{header|PascalABC.NET}}==
begin
repeat
Print(a);
until a mod 6 = 0;
end.
</syntaxhighlight>
=={{header|Perl}}==
Line 3,281 ⟶ 3,303:
endmodule
</syntaxhighlight>
▲=={{header|Wren}}==
Wren doesn't have a ''do/while'' loop as such but we can simulate it using an infinite loop with a final conditional break.▼
▲<syntaxhighlight lang="ecmascript">var v = 0
▲while (true) {
▲ v = v + 1
System.print(v)▼
▲ if (v%6 == 0) break
▲}</syntaxhighlight>
{{out}}▼
<pre>▼
1▼
2▼
3▼
4▼
5▼
6▼
</pre>▼
It can also be simulated ''without'' using a break statement as follows:▼
<syntaxhighlight lang="ecmascript">var value = 0▼
▲var ok = true
while (ok) {▼
value = value + 1▼
System.print(value)▼
ok = value%6 != 0▼
▲}</syntaxhighlight>
{{out}}▼
<pre>▼
Same as before.▼
</pre>▼
=={{header|V (Vlang)}}==
Line 3,369 ⟶ 3,360:
println(n3) // prt 8
}</syntaxhighlight>
=={{header|Wren}}==
▲Wren doesn't have a ''do/while'' loop as such but we can simulate it using an infinite loop with a final conditional break.
<syntaxhighlight lang="wren">var v = 0
while (true) {
v = v + 1
▲ System.print(v)
if (v%6 == 0) break
}</syntaxhighlight>
▲{{out}}
▲<pre>
▲1
▲2
▲3
▲4
▲5
▲6
▲</pre>
▲It can also be simulated ''without'' using a break statement as follows:
var ok = true
▲while (ok) {
▲ value = value + 1
▲ System.print(value)
▲ ok = value%6 != 0
}</syntaxhighlight>
▲{{out}}
▲<pre>
▲Same as before.
▲</pre>
=={{header|X86 Assembly}}==
|