fixing typos and grammar

This commit is contained in:
tovedetered 2024-05-04 13:29:42 -04:00
parent 63a6557d40
commit bf04adf091
10 changed files with 37 additions and 36 deletions

View File

@ -1,16 +1,16 @@
// //
// When Andrew Kelley announced the idea of a new programming language // When Andrew Kelley announced the idea of a new programming language
// - namely Zig - in his blog on February 8, 2016, he also immediately // - namely Zig - in his blog on February 8, 2016, he also immediately
// stated his ambitious goal: to replace the C language! // stated this ambitious goal: to replace the C language!
// //
// In order to be able to achieve this goal at all, Zig should be // In order to be able to achieve this goal at all, Zig should be
// as compatible as possible with its "predecessor". // as compatible as possible with its "predecessor".
// Only if it is possible to exchange individual modules in existing // Only if it is possible to exchange individual modules in existing
// C programs without having to use complicated wrappers, // C programs without having to use any complicated wrappers,
// the undertaking has a chance of success. // the undertaking has a chance of success.
// //
// So it is not surprising that calling C functions and vice versa // So it is not surprising that calling C functions and vice versa
// is extremely "smooth". // is extremely smooth.
// //
// To call C functions in Zig, you only need to specify the library // To call C functions in Zig, you only need to specify the library
// that contains said function. For this purpose there is a built-in // that contains said function. For this purpose there is a built-in

View File

@ -31,7 +31,7 @@
// } // }
// Instead of a simple integer or a constant sized slice, this // Instead of a simple integer or a constant sized slice, this
// program requires a slice to be allocated that is the same size as // program requires a slice to be allocated so that is the same size as
// an input array. // an input array.
// Given a series of numbers, take the running average. In other // Given a series of numbers, take the running average. In other

View File

@ -1,5 +1,5 @@
// //
// Bit manipulations is a very powerful tool just also from Zig. // Bit manipulation is a very powerful tool that Zig also supports.
// Since the dawn of the computer age, numerous algorithms have been // Since the dawn of the computer age, numerous algorithms have been
// developed that solve tasks solely by moving, setting, or logically // developed that solve tasks solely by moving, setting, or logically
// combining bits. // combining bits.
@ -8,9 +8,9 @@
// functions where possible. And it is often possible with calculations // functions where possible. And it is often possible with calculations
// based on integers. // based on integers.
// //
// Often it is not easy to understand at first glance what exactly these // Often it is not easy to understand at first glance exactly what these
// algorithms do when only "numbers" in memory areas change outwardly. // algorithms do when only "numbers" in memory areas change outwardly.
// But it must never be forgotten that the numbers only represent the // But it cannot be forgotten that the numbers only represent the
// interpretation of the bit sequences. // interpretation of the bit sequences.
// //
// Quasi the reversed case we have otherwise, namely that we represent // Quasi the reversed case we have otherwise, namely that we represent
@ -35,8 +35,8 @@
// const res5 = numOne ^ numTwo; // = 1111 1010 - xor // const res5 = numOne ^ numTwo; // = 1111 1010 - xor
// //
// //
// To familiarize ourselves with bit manipulation, we start with a simple // To familiarize ourselves with bit manipulation, let's start with a simple
// but often underestimated function and then add other exercises in // but often underestimated function and then add other exercises in a
// loose order. // loose order.
// //
// The following text contains excerpts from Wikipedia. // The following text contains excerpts from Wikipedia.
@ -63,8 +63,8 @@
// y := temp // y := temp
// //
// However, with integers we can also achieve the swap function simply by // However, with integers we can also achieve the swap function simply by
// bit manipulation. To do this, the variables are mutually linked with xor // using bit manipulation. To do this, the variables are mutually linked with
// and the result is the same. // xor and the result is the same.
const std = @import("std"); const std = @import("std");
const print = std.debug.print; const print = std.debug.print;

View File

@ -1,5 +1,5 @@
// //
// Another useful practice for bit manipulation is setting bits as flags. // Another useful application for bit manipulation is setting bits as flags.
// This is especially useful when processing lists of something and storing // This is especially useful when processing lists of something and storing
// the states of the entries, e.g. a list of numbers and for each prime // the states of the entries, e.g. a list of numbers and for each prime
// number a flag is set. // number a flag is set.
@ -19,12 +19,12 @@
// For example, you could take an array of bool and set the value to 'true' // For example, you could take an array of bool and set the value to 'true'
// for each letter in the order of the alphabet (a=0; b=1; etc.) found in // for each letter in the order of the alphabet (a=0; b=1; etc.) found in
// the sentence. However, this is neither memory efficient nor particularly // the sentence. However, this is neither memory efficient nor particularly
// fast. Instead we take a simpler way, very similar in principle, we define // fast. Instead we can take a simpler path, one that is
// a variable with at least 26 bits (e.g. u32) and also set the bit for each // very similar in principle. We define a variable with at least 26 bits (e.g. u32) \
// letter found at the corresponding position. // and also set the bit for each letter found at the corresponding position.
// //
// Zig provides functions for this in the standard library, but we prefer to // Zig provides functions for this in the standard library, but we should
// solve it without these extras, after all we want to learn something. // solve it without these extras; After all we want to learn something.
// //
const std = @import("std"); const std = @import("std");
const ascii = std.ascii; const ascii = std.ascii;

View File

@ -19,9 +19,9 @@
// https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig#L29 // https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig#L29
// //
// Zig already has a very nice selection of formatting options. // Zig already has a very nice selection of formatting options.
// These can be used in different ways, but typically to convert // These can be used in different ways, but they are typically used
// numerical values into various text representations. The // to convert numerical values into various text representations.
// results can be used for direct output to a terminal or stored // The results can be used for direct output to a terminal or stored
// for later use or written to a file. The latter is useful when // for later use or written to a file. The latter is useful when
// large amounts of data are to be processed by other programs. // large amounts of data are to be processed by other programs.
// //

View File

@ -1,13 +1,13 @@
// //
// We've seen that the 'for' loop can let us perform some action // We've seen that the 'for' loop can let us perform an action
// for every item in an array or slice. // for every item in an array or slice.
// //
// More recently, we discovered that it supports ranges to // More recently, we discovered that it supports ranges to
// iterate over number sequences. // iterate over number sequences.
// //
// This is part of a more general capability of the `for` loop: // This is part of a more general capability of the `for` loop:
// looping over one or more "objects" where an object is an // looping over one or more "objects" where an object is defined as
// array, slice, or range. // an array, slice, or range.
// //
// In fact, we *did* use multiple objects way back in Exercise // In fact, we *did* use multiple objects way back in Exercise
// 016 where we iterated over an array and also a numeric index. // 016 where we iterated over an array and also a numeric index.

View File

@ -1,12 +1,12 @@
// //
// A big advantage of Zig is the integration of its own test system. // A big advantage of Zig is the integration of its own test system.
// This allows the philosophy of Test Driven Development (TDD) to be // This allows the philosophy of Test Driven Development (TDD) to be
// implemented perfectly. Zig even goes one step further than other // implemented easily. Zig even goes one step further than other
// languages, the tests can be included directly in the source file. // languages, in that the tests can be included directly in the source file.
// //
// This has several advantages. On the one hand it is much clearer to // This has several advantages. On the one hand it is much clearer to
// have everything in one file, both the source code and the associated // have both the source code and the associated test code in one file.
// test code. On the other hand, it is much easier for third parties // On the other hand, it is much easier for third parties
// to understand what exactly a function is supposed to do if they can // to understand what exactly a function is supposed to do if they can
// simply look at the test inside the source and compare both. // simply look at the test inside the source and compare both.
// //
@ -16,7 +16,7 @@
// illustrate it with a small example including a test. // illustrate it with a small example including a test.
// //
// Therefore, in this exercise we will deal with the basics of testing // Therefore, in this exercise we will deal with the basics of testing
// in Zig. Basically, tests work as follows: you pass certain parameters // in Zig. Tests work as follows: you pass certain parameters
// to a function, for which you get a return - the result. This is then // to a function, for which you get a return - the result. This is then
// compared with the EXPECTED value. If both values match, the test is // compared with the EXPECTED value. If both values match, the test is
// passed, otherwise an error message is displayed. // passed, otherwise an error message is displayed.

View File

@ -1,20 +1,21 @@
// //
// The functionality of the standard library is becoming increasingly // The functionality of the standard library is becoming increasingly
// important in Zig. First of all, it is helpful to take a look at how // important to Zig. First of all, it is helpful to take a look at how
// the individual functions are implemented. Because this is wonderfully // the individual functions are implemented. Because this is wonderfully
// suitable as a template for your own functions. In addition these // suitable as a template for your own functions. In addition these
// standard functions are part of the basic configuration of Zig. // standard functions are part of the basic configuration and capabilities
// of Zig.
// //
// This means that they are always available on every system. // This means that they are always available on every system.
// Therefore it is worthwhile to deal with them also in Ziglings. // Therefore it is worthwhile to deal with them also in Ziglings.
// It's a great way to learn important skills. For example, it is // It's also a great way to learn important skills. For example, it's
// often necessary to process large amounts of data from files. // often necessary to process large amounts of data from files.
// And for this sequential reading and processing, Zig provides some // And for this sequential reading and processing, Zig provides some
// useful functions, which we will take a closer look at in the coming // useful functions, which we will take a closer look at in the coming
// exercises. // exercises.
// //
// A nice example of this has been published on the Zig homepage, // A nice example of this has been published on the Zig homepage,
// replacing the somewhat dusty 'Hello world! // replacing the somewhat dusty 'Hello world!'
// //
// Nothing against 'Hello world!', but it just doesn't do justice // Nothing against 'Hello world!', but it just doesn't do justice
// to the elegance of Zig and that's a pity, if someone takes a short, // to the elegance of Zig and that's a pity, if someone takes a short,

View File

@ -4,8 +4,8 @@
// one possibility, namely asynchronous processes, in Exercises 84-91. // one possibility, namely asynchronous processes, in Exercises 84-91.
// //
// However, the computing power of the processor is only distributed to // However, the computing power of the processor is only distributed to
// the started tasks, which always reaches its limits when pure computing // the started and running tasks, which always reaches its limits when
// power is called up. // pure computing power is called up.
// //
// For example, in blockchains based on proof of work, the miners have // For example, in blockchains based on proof of work, the miners have
// to find a nonce for a certain character string so that the first m bits // to find a nonce for a certain character string so that the first m bits

View File

@ -1,6 +1,6 @@
// //
// Now that we are familiar with the principles of multi threading, we // Now that we are familiar with the principles of multi-threading, we
// boldly venture into a practical example from mathematics. // shall boldly venture into a practical example from mathematics.
// We will determine the circle number PI with sufficient accuracy. // We will determine the circle number PI with sufficient accuracy.
// //
// There are different methods for this, and some of them are several // There are different methods for this, and some of them are several