Loops/For: Difference between revisions
Zig sorted alphabetically before zkn
m (→{{header|Wren}}: Changed to Wren S/H) |
(Zig sorted alphabetically before zkn) |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 590:
The key operator here is 'iter' which gives the current iteration of the loop body it
resides in. When used with the 'times' operator, it generates a countdown.
const ROWS := 5
for j := 1; j <= i; j += 1 {
print('*')
}
println('')
}
}
=={{header|bash}}==
Line 896 ⟶ 911:
| :-1<
^+1,+5+5<</syntaxhighlight>
=={{header|Binary Lambda Calculus}}==
The following 22-byte BLC program is generated from https://github.com/tromp/AIT/blob/master/rosetta/forloops.lam :
<pre>18 18 11 50 73 9c e7 40 b3 df cb df 38 1c bd a3 88 05 bb 00 2a 0a</pre>
=={{header|blz}}==
Line 1,496 ⟶ 1,517:
=={{header|Elena}}==
ELENA
<syntaxhighlight lang="elena">import extensions;
public program()
{
for(int i := 0
{
for(int j := 0
{ console.write
console.writeLine()
Line 2,279 ⟶ 2,300:
Or, with one for loop...
<syntaxhighlight lang="langur">for .i of 5 {
writeln "*"
}</syntaxhighlight>
Line 3,456 ⟶ 3,477:
=={{header|Seed7}}==
<syntaxhighlight lang="
$ include "seed7_05.s7i";
for J range 1 to I do▼
write("*");▼
const proc: main is func
end for;▼
local
writeln;▼
▲end for;</syntaxhighlight>
begin
for I range 1 to 5 do
▲ for J range 1 to I do
▲ write("*");
end for;
▲ writeln;
▲ end for;
end func;
</syntaxhighlight>
{{out}}
<pre>
*
**
***
****
*****
</pre>
=={{header|SETL}}==
Line 4,096 ⟶ 4,136:
pop bc
ret ; return to BASIC interpreter</syntaxhighlight>
=={{header|Zig}}==
const std = @import("std");
pub fn main() !void {
const stdout_wr = std.io.getStdOut().writer();▼
for (1..6) |n| {
for (0..n) |_| {
try stdout_wr.writeAll("*");▼
}▼
try stdout_wr.writeAll("\n");▼
}
}
</syntaxhighlight>
{{out}}
<pre>
*
**
***
****
*****
</pre>
=={{header|zkl}}==
Line 4,110 ⟶ 4,173:
*****
</pre>
▲=={{header|Zig}}==
▲<syntaxhighlight lang="zig">const std = @import("std");
▲pub fn main() !void {
▲ const stdout_wr = std.io.getStdOut().writer();
▲ var i: u8 = 1;
▲ while (i < 5) : (i += 1) {
▲ var j: u8 = 1;
▲ try stdout_wr.writeAll("*");
▲ try stdout_wr.writeAll("\n");
▲ }
▲}</syntaxhighlight>
|