fix whitespace line-endings

This commit is contained in:
Jonathan Halmen 2021-11-05 16:44:29 +01:00
parent 4c7eebbbfc
commit 29d32bfa79
19 changed files with 26 additions and 27 deletions

View file

@ -33,7 +33,7 @@ pub fn main() void {
// have a little preview of Zig 'for' loops instead: // have a little preview of Zig 'for' loops instead:
// //
// for (<item array>) |item| { <do something with item> } // for (<item array>) |item| { <do something with item> }
// //
// Don't worry, we'll cover looping properly in upcoming // Don't worry, we'll cover looping properly in upcoming
// lessons. // lessons.
// //

View file

@ -23,6 +23,6 @@ pub fn main() void {
0b1101000, // binary 0b1101000, // binary
0x66, // hex 0x66, // hex
}; };
print("{s} is cool.\n", .{zig}); print("{s} is cool.\n", .{zig});
} }

View file

@ -59,7 +59,7 @@ pub fn main() void {
// | exponent significand // | exponent significand
// | // |
// sign // sign
// //
// This example is the decimal number 3.140625, which happens to // This example is the decimal number 3.140625, which happens to
// be the closest representation of Pi we can make with an f16 // be the closest representation of Pi we can make with an f16
// due to the way IEEE-754 floating points store digits: // due to the way IEEE-754 floating points store digits:
@ -86,6 +86,6 @@ pub fn main() void {
// //
// Fun fact: sometimes you'll see the significand labeled as a // Fun fact: sometimes you'll see the significand labeled as a
// "mantissa" but Donald E. Knuth says not to do that. // "mantissa" but Donald E. Knuth says not to do that.
// //
// C compatibility fact: There is also a Zig floating point type // C compatibility fact: There is also a Zig floating point type
// specifically for working with C ABIs called c_longdouble. // specifically for working with C ABIs called c_longdouble.

View file

@ -22,7 +22,7 @@
// const arr: [3]u8 = [3]u8{5, 6, 7}; // const arr: [3]u8 = [3]u8{5, 6, 7};
// const s: []const u8 = &arr; // to slice // const s: []const u8 = &arr; // to slice
// const p: [*]const u8 = &arr; // to many-item pointer // const p: [*]const u8 = &arr; // to many-item pointer
// //
// 4. Single-item mutable pointers can coerce to single-item // 4. Single-item mutable pointers can coerce to single-item
// pointers pointing to an array of length 1. (Interesting!) // pointers pointing to an array of length 1. (Interesting!)
// //

View file

@ -1,7 +1,7 @@
// //
// The Zig compiler provides "builtin" functions. You've already // The Zig compiler provides "builtin" functions. You've already
// gotten used to seeing an @import() at the top of every // gotten used to seeing an @import() at the top of every
// Ziglings exercise. // Ziglings exercise.
// //
// We've also seen @intCast() in "016_for2.zig", "058_quiz7.zig"; // We've also seen @intCast() in "016_for2.zig", "058_quiz7.zig";
// and @enumToInt() in "036_enums2.zig". // and @enumToInt() in "036_enums2.zig".
@ -51,7 +51,7 @@ pub fn main() void {
// 1111 + 1 = 0000 Yes! (Real answer is 10000) // 1111 + 1 = 0000 Yes! (Real answer is 10000)
// 0000 + 1 = 0001 Yes! // 0000 + 1 = 0001 Yes!
// 0001 + 1 = 0010 Yes! // 0001 + 1 = 0010 Yes!
// //
// Also, check out our fancy formatting! b:0>4 means, "print // Also, check out our fancy formatting! b:0>4 means, "print
// as a binary number, zero-pad right-aligned four digits." // as a binary number, zero-pad right-aligned four digits."
print("{b:0>4} + {b:0>4} = {b:0>4} ({})", .{a, b, my_result, overflowed}); print("{b:0>4} + {b:0>4} = {b:0>4} ({})", .{a, b, my_result, overflowed});

View file

@ -1,7 +1,7 @@
// //
// Zig has builtins for mathematical operations such as... // Zig has builtins for mathematical operations such as...
// //
// @sqrt @sin @cos // @sqrt @sin @cos
// @exp @log @floor // @exp @log @floor
// //
// ...and lots of type casting operations such as... // ...and lots of type casting operations such as...
@ -20,18 +20,18 @@
// by exploring just THREE of Zig's MANY introspection abilities: // by exploring just THREE of Zig's MANY introspection abilities:
// //
// 1. @This() type // 1. @This() type
// //
// Returns the innermost struct, enum, or union that a function // Returns the innermost struct, enum, or union that a function
// call is inside. // call is inside.
// //
// 2. @typeInfo(comptime T: type) @import("std").builtin.TypeInfo // 2. @typeInfo(comptime T: type) @import("std").builtin.TypeInfo
// //
// Returns information about any type in a TypeInfo union which // Returns information about any type in a TypeInfo union which
// will contain different information depending on which type // will contain different information depending on which type
// you're examining. // you're examining.
// //
// 3. @TypeOf(...) type // 3. @TypeOf(...) type
// //
// Returns the type common to all input parameters (each of which // Returns the type common to all input parameters (each of which
// may be any expression). The type is resolved using the same // may be any expression). The type is resolved using the same
// "peer type resolution" process the compiler itself uses when // "peer type resolution" process the compiler itself uses when
@ -46,7 +46,7 @@ const Narcissus = struct {
me: *Narcissus = undefined, me: *Narcissus = undefined,
myself: *Narcissus = undefined, myself: *Narcissus = undefined,
echo: void = undefined, echo: void = undefined,
fn fetchTheMostBeautifulType() type { fn fetchTheMostBeautifulType() type {
return @This(); return @This();
} }

View file

@ -27,7 +27,7 @@
// //
// Zig takes these concepts further by making these optimizations // Zig takes these concepts further by making these optimizations
// an integral part of the language itself! // an integral part of the language itself!
// //
const print = @import("std").debug.print; const print = @import("std").debug.print;
pub fn main() void { pub fn main() void {

View file

@ -8,7 +8,7 @@
// --o-- comptime * | .. . // --o-- comptime * | .. .
// * | * . . . . --*-- . * . // * | * . . . . --*-- . * .
// . . . . . . . . . | . . . // . . . . . . . . . | . . .
// //
// When placed before a variable declaration, 'comptime' // When placed before a variable declaration, 'comptime'
// guarantees that every usage of that variable will be performed // guarantees that every usage of that variable will be performed
// at compile time. // at compile time.

View file

@ -49,6 +49,6 @@ fn makeSequence(comptime T: type, ??? size: usize) [???]T {
while (i < size) : (i += 1) { while (i < size) : (i += 1) {
sequence[i] = @intCast(T, i) + 1; sequence[i] = @intCast(T, i) + 1;
} }
return sequence; return sequence;
} }

View file

@ -140,6 +140,6 @@ fn isADuck(possible_duck: anytype) bool {
// error, not a runtime panic or crash! // error, not a runtime panic or crash!
possible_duck.quack(); possible_duck.quack();
} }
return is_duck; return is_duck;
} }

View file

@ -49,7 +49,7 @@ pub fn main() void {
'*' => value *= digit, '*' => value *= digit,
else => unreachable, else => unreachable,
} }
// ...But it's quite a bit more exciting than it first appears. // ...But it's quite a bit more exciting than it first appears.
// The 'inline while' no longer exists at runtime and neither // The 'inline while' no longer exists at runtime and neither
// does anything else not touched directly by runtime // does anything else not touched directly by runtime
// code. The 'instructions' string, for example, does not // code. The 'instructions' string, for example, does not
@ -61,6 +61,6 @@ pub fn main() void {
// code at compile time. Guess we're compiler writers // code at compile time. Guess we're compiler writers
// now. See? The wizard hat was justified after all. // now. See? The wizard hat was justified after all.
} }
print("{}\n", .{value}); print("{}\n", .{value});
} }

View file

@ -56,7 +56,7 @@ fn getLlama(i: usize) u32 {
} }
// Fun fact: this assert() function is identical to // Fun fact: this assert() function is identical to
// std.debug.assert() from the Zig Standard Library. // std.debug.assert() from the Zig Standard Library.
fn assert(ok: bool) void { fn assert(ok: bool) void {
if (!ok) unreachable; if (!ok) unreachable;
} }

View file

@ -69,7 +69,7 @@ const f_paths = [_]Path{ makePath(&f, &d, 7) };
// //
// For example, we could create our own "path language" and // For example, we could create our own "path language" and
// create Paths from that. Something like this, perhaps: // create Paths from that. Something like this, perhaps:
// //
// a -> (b[2]) // a -> (b[2])
// b -> (a[2] d[1]) // b -> (a[2] d[1])
// c -> (d[3] e[2]) // c -> (d[3] e[2])

View file

@ -22,7 +22,7 @@
// Versatility! Zig strings are compatible with C strings (which // Versatility! Zig strings are compatible with C strings (which
// are null-terminated) AND can be coerced to a variety of other // are null-terminated) AND can be coerced to a variety of other
// Zig types: // Zig types:
// //
// const a: [5]u8 = "array".*; // const a: [5]u8 = "array".*;
// const b: *const [16]u8 = "pointer to array"; // const b: *const [16]u8 = "pointer to array";
// const c: []const u8 = "slice"; // const c: []const u8 = "slice";

View file

@ -13,7 +13,7 @@
// past the authorities: the @"" identifier quoting syntax. // past the authorities: the @"" identifier quoting syntax.
// //
// @"foo" // @"foo"
// //
// Please help us safely smuggle these fugitive identifiers into // Please help us safely smuggle these fugitive identifiers into
// our program: // our program:
// //

View file

@ -29,7 +29,7 @@
// If a .{} thing is what the print function wants, do we need to // If a .{} thing is what the print function wants, do we need to
// break our "tuple" apart and put it in another one? No! It's // break our "tuple" apart and put it in another one? No! It's
// redundant! This will print the same thing: // redundant! This will print the same thing:
// //
// print("{} {}\n", foo); // print("{} {}\n", foo);
// //
// Aha! So now we know that print() takes a "tuple". Things are // Aha! So now we know that print() takes a "tuple". Things are

View file

@ -37,7 +37,7 @@
// fn bar() void { // fn bar() void {
// fooThatSuspends(); // fooThatSuspends();
// } // }
// //
// 6. The main() function cannot be async! // 6. The main() function cannot be async!
// //
// Given facts 3 and 4, how do we fix this program (broken by facts // Given facts 3 and 4, how do we fix this program (broken by facts

View file

@ -26,4 +26,3 @@ fn foo() void {
suspend {} suspend {}
print("async!\n", .{}); print("async!\n", .{});
} }

View file

@ -10,7 +10,7 @@
// fn bar() void { // fn bar() void {
// fooThatMightSuspend(true); // Now bar() is async! // fooThatMightSuspend(true); // Now bar() is async!
// } // }
// //
// But if you KNOW the function won't suspend, you can make a // But if you KNOW the function won't suspend, you can make a
// promise to the compiler with the 'nosuspend' keyword: // promise to the compiler with the 'nosuspend' keyword:
// //