mirror of
https://codeberg.org/ziglings/exercises.git
synced 2025-04-01 05:45:29 +01:00
fix: typos
This commit is contained in:
parent
7ce659f7fa
commit
522b4673a4
8 changed files with 14 additions and 14 deletions
|
@ -200,7 +200,7 @@ pub fn build(b: *Build) !void {
|
|||
|
||||
if (rand) |_| {
|
||||
// Random build mode: verifies one random exercise.
|
||||
// like for 'exno' but chooses a random exersise number.
|
||||
// like for 'exno' but chooses a random exercise number.
|
||||
print("work in progress: check a random exercise\n", .{});
|
||||
|
||||
var prng = std.Random.DefaultPrng.init(blk: {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//
|
||||
// if (foo) |value| {
|
||||
// ...
|
||||
// } else |err| switch(err) {
|
||||
// } else |err| switch (err) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// doing this work.
|
||||
//
|
||||
// An 'inline for' is performed at compile time, allowing you to
|
||||
// programatically loop through a series of items in situations
|
||||
// programmatically loop through a series of items in situations
|
||||
// like those mentioned above where a regular runtime 'for' loop
|
||||
// wouldn't be allowed:
|
||||
//
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
// There were the Scottish mathematician Gregory and the German
|
||||
// mathematician Leibniz, and even a few hundred years earlier the Indian
|
||||
// mathematician Madhava. All of them independently developed the same
|
||||
// formula, which was published by Leibnitz in 1682 in the journal
|
||||
// formula, which was published by Leibniz in 1682 in the journal
|
||||
// "Acta Eruditorum".
|
||||
// This is why this method has become known as the "Leibnitz series",
|
||||
// This is why this method has become known as the "Leibniz series",
|
||||
// although the other names are also often used today.
|
||||
// We will not go into the formula and its derivation in detail, but
|
||||
// will deal with the series straight away:
|
||||
|
@ -50,7 +50,7 @@
|
|||
// enough for us for now, because we want to understand the principle and
|
||||
// nothing more, right?
|
||||
//
|
||||
// As we have already discovered, the Leibnitz series is a series with a
|
||||
// As we have already discovered, the Leibniz series is a series with a
|
||||
// fixed distance of 2 between the individual partial values. This makes
|
||||
// it easy to apply a simple loop to it, because if we start with n = 1
|
||||
// (which is not necessarily useful now) we always have to add 2 in each
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// Alright, bud, lean in close. Here's the game plan.
|
||||
// - First, we open the {project_root}/output/ directory
|
||||
// - Secondly, we open file `zigling.txt` in that directory
|
||||
// - Then, we initalize an array of characters with all letter 'A', and print it
|
||||
// - Then, we initialize an array of characters with all letter 'A', and print it
|
||||
// - After that, we read the content of the file into the array
|
||||
// - Finally, we print out the content we just read
|
||||
|
||||
|
@ -30,9 +30,9 @@ pub fn main() !void {
|
|||
const file = try output_dir.openFile("zigling.txt", .{});
|
||||
defer file.close();
|
||||
|
||||
// initalize an array of u8 with all letter 'A'
|
||||
// initialize an array of u8 with all letter 'A'
|
||||
// we need to pick the size of the array, 64 seems like a good number
|
||||
// fix the initalization below
|
||||
// fix the initialization below
|
||||
var content = ['A']*64;
|
||||
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`
|
||||
std.debug.print("{s}\n", .{content});
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
//
|
||||
// By combining all we've learned so far, we can now proceed with a labeled switch
|
||||
//
|
||||
// A labeled switch is some extra syntatic sugar, which comes with all sorts of
|
||||
// A labeled switch is some extra syntactic sugar, which comes with all sorts of
|
||||
// candy (performance benefits). Don't believe me? Directly to source https://github.com/ziglang/zig/pull/21367
|
||||
//
|
||||
// Here is the previous excerpt implemented as a labeled switch instead:
|
||||
|
|
|
@ -161,7 +161,7 @@ pub fn main() !void {
|
|||
// In order to output a 1, the logic of an XOR operation requires that the
|
||||
// two input bits are of different values. Therefore, 0 ^ 1 and 1 ^ 0 will
|
||||
// both yield a 1 but 0 ^ 0 and 1 ^ 1 will output 0. XOR's unique behavior
|
||||
// of outputing a 0 when both inputs are 1s is what makes it different from
|
||||
// of outputting a 0 when both inputs are 1s is what makes it different from
|
||||
// the OR operator; it also gives us the ability to toggle bits by putting
|
||||
// 1s into our bitmask.
|
||||
//
|
||||
|
@ -247,7 +247,7 @@ pub fn main() !void {
|
|||
// PORTB = PORTB & 0b1011;
|
||||
// print("PORTB: {b:0>4}\n", .{PORTB}); // output -> 1010
|
||||
//
|
||||
// - 0s clear bits when used in conjuction with a bitwise AND.
|
||||
// - 0s clear bits when used in conjunction with a bitwise AND.
|
||||
// - 1s do nothing, thus preserving the original bits.
|
||||
//
|
||||
// -AND op- ---expanded---
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
--- exercises/107_files2.zig 2025-03-13 15:26:59.532367792 +0200
|
||||
+++ answers/107_files2.zig 2025-03-14 22:08:35.167953736 +0200
|
||||
@@ -33,7 +33,7 @@
|
||||
// initalize an array of u8 with all letter 'A'
|
||||
// initialize an array of u8 with all letter 'A'
|
||||
// we need to pick the size of the array, 64 seems like a good number
|
||||
// fix the initalization below
|
||||
// fix the initialization below
|
||||
- var content = ['A']*64;
|
||||
+ var content = [_]u8{'A'} ** 64;
|
||||
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`
|
||||
|
|
Loading…
Reference in a new issue