From f86b769f6288935f738b692e13ab8786553a0060 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Fri, 7 Jun 2024 07:10:44 -0400 Subject: [PATCH] 072-074 completed --- exercises/072_comptime7.zig | 2 +- exercises/073_comptime8.zig | 4 ++-- exercises/074_comptime9.zig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/072_comptime7.zig b/exercises/072_comptime7.zig index 631e75b..1bdcc1a 100644 --- a/exercises/072_comptime7.zig +++ b/exercises/072_comptime7.zig @@ -35,7 +35,7 @@ pub fn main() void { // at compile time. // // Please fix this to loop once per "instruction": - ??? (i < instructions.len) : (???) { + inline while (i < instructions.len) : (i += 3) { // This gets the digit from the "instruction". Can you // figure out why we subtract '0' from it? diff --git a/exercises/073_comptime8.zig b/exercises/073_comptime8.zig index fe1f8ea..2e69566 100644 --- a/exercises/073_comptime8.zig +++ b/exercises/073_comptime8.zig @@ -32,12 +32,12 @@ const llamas = [llama_count]u32{ 5, 10, 15, 20, 25 }; pub fn main() void { // We meant to fetch the last llama. Please fix this simple // mistake so the assertion no longer fails. - const my_llama = getLlama(5); + const my_llama = getLlama(4); print("My llama value is {}.\n", .{my_llama}); } -fn getLlama(i: usize) u32 { +fn getLlama(comptime i: usize) u32 { // We've put a guard assert() at the top of this function to // prevent mistakes. The 'comptime' keyword here means that // the mistake will be caught when we compile! diff --git a/exercises/074_comptime9.zig b/exercises/074_comptime9.zig index 4088aad..5eaa6fd 100644 --- a/exercises/074_comptime9.zig +++ b/exercises/074_comptime9.zig @@ -39,7 +39,7 @@ const llamas = makeLlamas(llama_count); // And here's the function. Note that the return value type // depends on one of the input arguments! -fn makeLlamas(count: usize) [count]u8 { +fn makeLlamas(comptime count: usize) [count]u8 { var temp: [count]u8 = undefined; var i = 0;