Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Loops-Do-while/Zig/loops-do-while.zig
Normal file
15
Task/Loops-Do-while/Zig/loops-do-while.zig
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var a: u8 = 0;
|
||||
// no do-while in syntax, trust the optimizer to do
|
||||
// correct Loop inversion https://en.wikipedia.org/wiki/Loop_inversion
|
||||
// If the variable `alive` is independent to other variables and not in
|
||||
// diverging control flow, then the optimization is possible in general.
|
||||
var alive = true;
|
||||
while (alive == true or a % 6 != 0) {
|
||||
alive = false;
|
||||
a += 1;
|
||||
try std.io.getStdOut().writer().print("{d}\n", .{a});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue