mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-11-08 11:20:46 -05:00
072-074 completed
This commit is contained in:
parent
9c26298549
commit
f86b769f62
3 changed files with 4 additions and 4 deletions
|
@ -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?
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue