diff options
author | Dave Gauer <dave@ratfactor.com> | 2021-03-12 18:59:46 -0500 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2021-03-12 18:59:46 -0500 |
commit | 6ad9774189fbd64b2f2c9519f4513ab34b0c3809 (patch) | |
tree | d6c90700131d5b28e898881f13e2a05612e4703f /exercises/04_arrays.zig | |
parent | be36352572ddb18218e1830e49316c259dea5e8c (diff) | |
download | ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.tar.gz ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.tar.bz2 ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.tar.xz ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.zip |
"999 is enough for anybody" triple-zero padding (#18)
When I hit 999 exercises, I will finally have reached the ultimate
state of soteriological release and no more exercises will be needed.
The cycle will be complete. All that will be left is perfect quietude,
freedom, and highest happiness.
Diffstat (limited to 'exercises/04_arrays.zig')
-rw-r--r-- | exercises/04_arrays.zig | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/exercises/04_arrays.zig b/exercises/04_arrays.zig deleted file mode 100644 index 88fcc78..0000000 --- a/exercises/04_arrays.zig +++ /dev/null @@ -1,52 +0,0 @@ -// -// Let's learn some array basics. Arrays are declared with: -// -// var foo: [3]u32 = [3]u32{ 42, 108, 5423 }; -// -// When Zig can infer the size of the array, you can use '_' for the -// size. You can also let Zig infer the type of the value so the -// declaration is much less verbose. -// -// var foo = [_]u32{ 42, 108, 5423 }; -// -// Get values of an array using array[index] notation: -// -// const bar = foo[2]; // 5423 -// -// Set values of an array using array[index] notation: -// -// foo[2] = 16; -// -// Get the length of an array using the len property: -// -// const length = foo.len; -// -const std = @import("std"); - -pub fn main() void { - // (Problem 1) - // This "const" is going to cause a problem later - can you see what it is? - // How do we fix it? - const some_primes = [_]u8{ 1, 3, 5, 7, 11, 13, 17, 19 }; - - // Individual values can be set with '[]' notation. - // Example: This line changes the first prime to 2 (which is correct): - some_primes[0] = 2; - - // Individual values can also be accessed with '[]' notation. - // Example: This line stores the first prime in "first": - const first = some_primes[0]; - - // (Problem 2) - // Looks like we need to complete this expression. Use the example - // above to set "fourth" to the fourth element of the some_primes array: - const fourth = some_primes[???]; - - // (Problem 3) - // Use the len property to get the length of the array: - const length = some_primes.???; - - std.debug.print("First: {}, Fourth: {}, Length: {}\n", .{ - first, fourth, length, - }); -} |