1
0
Fork 0
mirror of https://codeberg.org/ziglings/exercises.git synced 2025-06-08 10:07:01 +09:00

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
// - 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
// as compatible as possible with its "predecessor".
// 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.
//
// 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
// 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
// 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.
// 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
// developed that solve tasks solely by moving, setting, or logically
// combining bits.
@ -8,9 +8,9 @@
// functions where possible. And it is often possible with calculations
// 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.
// 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.
//
// Quasi the reversed case we have otherwise, namely that we represent
@ -35,8 +35,8 @@
// const res5 = numOne ^ numTwo; // = 1111 1010 - xor
//
//
// To familiarize ourselves with bit manipulation, we start with a simple
// but often underestimated function and then add other exercises in
// To familiarize ourselves with bit manipulation, let's start with a simple
// but often underestimated function and then add other exercises in a
// loose order.
//
// The following text contains excerpts from Wikipedia.
@ -63,8 +63,8 @@
// y := temp
//
// However, with integers we can also achieve the swap function simply by
// bit manipulation. To do this, the variables are mutually linked with xor
// and the result is the same.
// using bit manipulation. To do this, the variables are mutually linked with
// xor and the result is the same.
const std = @import("std");
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
// the states of the entries, e.g. a list of numbers and for each prime
// 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 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
// fast. Instead we take a simpler way, very similar in principle, we define
// a variable with at least 26 bits (e.g. u32) and also set the bit for each
// letter found at the corresponding position.
// fast. Instead we can take a simpler path, one that is
// very similar in principle. We define a variable with at least 26 bits (e.g. u32) \
// 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
// solve it without these extras, after all we want to learn something.
// Zig provides functions for this in the standard library, but we should
// solve it without these extras; After all we want to learn something.
//
const std = @import("std");
const ascii = std.ascii;

View file

@ -19,9 +19,9 @@
// https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig#L29
//
// Zig already has a very nice selection of formatting options.
// These can be used in different ways, but typically to convert
// numerical values into various text representations. The
// results can be used for direct output to a terminal or stored
// These can be used in different ways, but they are typically used
// to convert numerical values into various text representations.
// 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
// 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.
//
// More recently, we discovered that it supports ranges to
// iterate over number sequences.
//
// This is part of a more general capability of the `for` loop:
// looping over one or more "objects" where an object is an
// array, slice, or range.
// looping over one or more "objects" where an object is defined as
// an array, slice, or range.
//
// In fact, we *did* use multiple objects way back in Exercise
// 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.
// This allows the philosophy of Test Driven Development (TDD) to be
// implemented perfectly. Zig even goes one step further than other
// languages, the tests can be included directly in the source file.
// implemented easily. Zig even goes one step further than other
// 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
// have everything in one file, both the source code and the associated
// test code. On the other hand, it is much easier for third parties
// have both the source code and the associated test code in one file.
// On the other hand, it is much easier for third parties
// to understand what exactly a function is supposed to do if they can
// simply look at the test inside the source and compare both.
//
@ -16,7 +16,7 @@
// illustrate it with a small example including a test.
//
// 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
// compared with the EXPECTED value. If both values match, the test is
// passed, otherwise an error message is displayed.

View file

@ -1,20 +1,21 @@
//
// 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
// 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.
// 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.
// And for this sequential reading and processing, Zig provides some
// useful functions, which we will take a closer look at in the coming
// exercises.
//
// 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
// 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.
//
// However, the computing power of the processor is only distributed to
// the started tasks, which always reaches its limits when pure computing
// power is called up.
// the started and running tasks, which always reaches its limits when
// pure computing power is called up.
//
// 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

View file

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