072-074 completed

This commit is contained in:
Andrew Scott 2024-06-07 07:10:44 -04:00
parent 9c26298549
commit f86b769f62
Signed by: a
GPG key ID: 7CD5A5977E4931C1
3 changed files with 4 additions and 4 deletions

View file

@ -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?

View file

@ -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!

View file

@ -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;