Jump to content

Loops/Continue: Difference between revisions

add Zig example
(→‎{{header|Picat}}: Adding Picat)
(add Zig example)
Line 2,636:
<lang zkl>foreach n in ([1..10]){print(n); if(n%5==0){println(); continue;} print(", ")}
// or foreach n in ([1..10]){print(n,(n%5) and ", " or "\n")}</lang>
 
=={{header|Zig}}==
<lang zig>const std = @import("std");
 
pub fn main() !void {
const stdout_wr = std.io.getStdOut().writer();
var i: i8 = 1;
while (i <= 10) : (i += 1) {
try stdout_wr.print("{d}", .{i});
if (i == 5) {
try stdout_wr.writeAll("\n");
continue;
}
try stdout_wr.writeAll(", ");
}
}</lang>
37

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.