Last active
June 22, 2019 21:01
-
-
Save CurtisFenner/30f2c0aa76cfd23a4119603c81e31609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn runtime(x: u32) bool { | |
return x % 2 != 0 and x % 3 != 0 and x % 5 != 0 and x % 7 != 0 and x % 11 != 0; | |
} | |
fn loopLegal(comptime arr: var) void { | |
inline for (arr) |e, i| { | |
while (true) { | |
if (!runtime(i)) { | |
break; | |
} | |
std.debug.warn("v: {}, {}\n", i, e); | |
break; | |
} | |
} | |
} | |
fn loopIllegal(comptime arr: var) void { | |
inline for (arr) |e, i| { | |
if (!runtime(i)) { | |
continue; | |
} | |
std.debug.warn("v: {}, {}\n", i, ie); | |
} | |
} | |
test "Simple" { | |
loopLegal("Show all the prime indices of this array"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment