Box the compass: Difference between revisions
m
→{{header|Zig}}: Updated to use 0.11.0 enum casts
(add RPL) |
Recombinant (talk | contribs) m (→{{header|Zig}}: Updated to use 0.11.0 enum casts) |
||
Line 7,804:
=={{header|Zig}}==
{{works with|Zig|0.11.
<syntaxhighlight lang="zig">const std = @import("std");</syntaxhighlight>
<syntaxhighlight lang="zig">/// Degrees
fn degreesToCompassPoint(degrees: f32) []const u8 {
var d = degrees + comptime (11.25 / 2.0);
while (d < 0) d += 360;
while (d >= 360) d -= 360;
const index: usize = @
"North", "North by east", "North-northeast", "Northeast by north",
▲ const points: [32][]const u8 = comptime .{} ++
};
return points[index];
Line 7,829:
const stdout = std.io.getStdOut().writer();
for (0..33) |i| {
var heading = @
heading += switch (i % 3) {
1 => 5.62,
Line 7,839:
};
const index = i % 32 + 1;
}
}</syntaxhighlight>
|