diff --git a/exercises/018_functions.zig b/exercises/018_functions.zig index 1f78438..c9cc6c5 100644 --- a/exercises/018_functions.zig +++ b/exercises/018_functions.zig @@ -25,6 +25,6 @@ pub fn main() void { // We're just missing a couple things. One thing we're NOT missing is the // keyword "pub", which is not needed here. Can you guess why? // -??? deepThought() ??? { +fn deepThought() u8 { return 42; // Number courtesy Douglas Adams } diff --git a/exercises/019_functions2.zig b/exercises/019_functions2.zig index a527ae2..71ede43 100644 --- a/exercises/019_functions2.zig +++ b/exercises/019_functions2.zig @@ -22,7 +22,7 @@ pub fn main() void { // You'll need to figure out the parameter name and type that we're // expecting. The output type has already been specified for you. // -fn twoToThe(???) u32 { +fn twoToThe(my_number: u32) u32 { return std.math.pow(u32, 2, my_number); // std.math.pow(type, a, b) takes a numeric type and two // numbers of that type (or that can coerce to that type) and diff --git a/exercises/020_quiz3.zig b/exercises/020_quiz3.zig index 571628e..2284999 100644 --- a/exercises/020_quiz3.zig +++ b/exercises/020_quiz3.zig @@ -21,8 +21,8 @@ pub fn main() void { // // This function prints, but does not return anything. // -fn printPowersOfTwo(numbers: [4]u16) ??? { - loop (numbers) |n| { +fn printPowersOfTwo(numbers: [4]u16) void { + for (numbers) |n| { std.debug.print("{} ", .{twoToThe(n)}); } } @@ -31,13 +31,13 @@ fn printPowersOfTwo(numbers: [4]u16) ??? { // exercise. But don't be fooled! This one does the math without the aid // of the standard library! // -fn twoToThe(number: u16) ??? { +fn twoToThe(number: u16) u16 { var n: u16 = 0; var total: u16 = 1; - loop (n < number) : (n += 1) { + while (n < number) : (n += 1) { total *= 2; } - return ???; + return total; }