summaryrefslogtreecommitdiffstatshomepage
path: root/exercises
diff options
context:
space:
mode:
Diffstat (limited to 'exercises')
-rw-r--r--exercises/016_for2.zig3
-rw-r--r--exercises/058_quiz7.zig2
-rw-r--r--exercises/069_comptime4.zig2
-rw-r--r--exercises/075_quiz8.zig2
-rw-r--r--exercises/096_memory_allocation.zig3
-rw-r--r--exercises/098_bit_manipulation2.zig2
6 files changed, 8 insertions, 6 deletions
diff --git a/exercises/016_for2.zig b/exercises/016_for2.zig
index 0eda182..6fb7844 100644
--- a/exercises/016_for2.zig
+++ b/exercises/016_for2.zig
@@ -29,7 +29,8 @@ pub fn main() void {
// Note that we convert the usize i to a u32 with
// @intCast(), a builtin function just like @import().
// We'll learn about these properly in a later exercise.
- const place_value = std.math.pow(u32, 2, @intCast(u32, i));
+ const i_u32: u32 = @intCast(i);
+ const place_value = std.math.pow(u32, 2, i_u32);
value += place_value * bit;
}
diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig
index 1ceac5a..bbdebf6 100644
--- a/exercises/058_quiz7.zig
+++ b/exercises/058_quiz7.zig
@@ -429,7 +429,7 @@ fn printTrip(trip: []?TripItem) void {
// We convert the usize length to a u8 with @intCast(), a
// builtin function just like @import(). We'll learn about
// these properly in a later exercise.
- var i: u8 = @intCast(u8, trip.len);
+ var i: u8 = @intCast(trip.len);
while (i > 0) {
i -= 1;
diff --git a/exercises/069_comptime4.zig b/exercises/069_comptime4.zig
index f4c8bbb..e090bb3 100644
--- a/exercises/069_comptime4.zig
+++ b/exercises/069_comptime4.zig
@@ -47,7 +47,7 @@ fn makeSequence(comptime T: type, ??? size: usize) [???]T {
var i: usize = 0;
while (i < size) : (i += 1) {
- sequence[i] = @intCast(T, i) + 1;
+ sequence[i] = @as(T, @intCast(i)) + 1;
}
return sequence;
diff --git a/exercises/075_quiz8.zig b/exercises/075_quiz8.zig
index d54864c..12b460c 100644
--- a/exercises/075_quiz8.zig
+++ b/exercises/075_quiz8.zig
@@ -204,7 +204,7 @@ pub fn main() void {
}
fn printTrip(trip: []?TripItem) void {
- var i: u8 = @intCast(u8, trip.len);
+ var i: u8 = @intCast(trip.len);
while (i > 0) {
i -= 1;
diff --git a/exercises/096_memory_allocation.zig b/exercises/096_memory_allocation.zig
index 7538ba4..c8d7bf6 100644
--- a/exercises/096_memory_allocation.zig
+++ b/exercises/096_memory_allocation.zig
@@ -45,7 +45,8 @@ fn runningAverage(arr: []const f64, avg: []f64) void {
for (0.., arr) |index, val| {
sum += val;
- avg[index] = sum / @floatFromInt(f64, index + 1);
+ const f_index: f64 = @floatFromInt(index + 1);
+ avg[index] = sum / f_index;
}
}
diff --git a/exercises/098_bit_manipulation2.zig b/exercises/098_bit_manipulation2.zig
index 9323548..e39486f 100644
--- a/exercises/098_bit_manipulation2.zig
+++ b/exercises/098_bit_manipulation2.zig
@@ -53,7 +53,7 @@ fn isPangram(str: []const u8) bool {
// and are numbered sequentially, we simply subtract the
// first letter (in this case the 'a') from the character
// found, and thus get the position of the desired bit
- bits |= @as(u32, 1) << @truncate(u5, ascii.toLower(c) - 'a');
+ bits |= @as(u32, 1) << @truncate(ascii.toLower(c) - 'a');
}
}
// last we return the comparison if all 26 bits are set,