Merge branch 'ratfactor:main' into testing

pull/2/head
Chris Boesch 1 year ago committed by GitHub
commit 2cb6975b13

@ -11,7 +11,7 @@
// ... // ...
// } // }
// //
// Perhaps knowing this well help solve the errors we're getting // Perhaps knowing this will help solve the errors we're getting
// with this little program? // with this little program?
// //
const std = @import("std"); const std = @import("std");

@ -1,6 +1,6 @@
// //
// There is also an 'inline while'. Just like 'inline for', it // There is also an 'inline while'. Just like 'inline for', it
// loops at compile time, allowing you do all sorts of // loops at compile time, allowing you to do all sorts of
// interesting things not possible at runtime. See if you can // interesting things not possible at runtime. See if you can
// figure out what this rather bonkers example prints: // figure out what this rather bonkers example prints:
// //

@ -69,7 +69,7 @@ pub fn main() void {
} }
// Here's our generic sequence printing function. It's nearly // Here's our generic sequence printing function. It's nearly
// complete, but there are a couple missing bits. Please fix // complete, but there are a couple of missing bits. Please fix
// them! // them!
fn printSequence(my_seq: anytype) void { fn printSequence(my_seq: anytype) void {
const my_typeinfo = @typeInfo(@TypeOf(my_seq)); const my_typeinfo = @typeInfo(@TypeOf(my_seq));

@ -86,7 +86,7 @@ const Insect = union(enum) {
// Thanks to 'inline else', we can think of this print() as // Thanks to 'inline else', we can think of this print() as
// being an interface method. Any member of this union with // being an interface method. Any member of this union with
// with a print() method can be treated uniformly by outside // a print() method can be treated uniformly by outside
// code without needing to know any other details. Cool! // code without needing to know any other details. Cool!
pub fn print(self: Insect) void { pub fn print(self: Insect) void {
switch (self) { switch (self) {

@ -27,7 +27,7 @@
// std.debug.print("ptr={*}\n", .{ptr}); // std.debug.print("ptr={*}\n", .{ptr});
// //
// const slice_ptr = try allocator.alloc(f64, 5); // const slice_ptr = try allocator.alloc(f64, 5);
// std.debug.print("ptr={*}\n", .{ptr}); // std.debug.print("slice_ptr={*}\n", .{slice_ptr});
// } // }
// Instead of an simple integer or a constant sized slice, this // Instead of an simple integer or a constant sized slice, this

@ -39,7 +39,7 @@ fn isPangram(str: []const u8) bool {
// first we check if the string has at least 26 characters // first we check if the string has at least 26 characters
if (str.len < 26) return false; if (str.len < 26) return false;
// we uses a 32 bit variable of which we need 26 bit // we uses a 32 bit variable of which we need 26 bits
var bits: u32 = 0; var bits: u32 = 0;
// loop about all characters in the string // loop about all characters in the string
@ -50,8 +50,8 @@ fn isPangram(str: []const u8) bool {
// //
// to do this, we use a little trick: // to do this, we use a little trick:
// since the letters in the ASCI table start at 65 // since the letters in the ASCI table start at 65
// and are numbered by, we simply subtract the first // and are numbered sequentially, we simply subtract the
// letter (in this case the 'a') from the character // first letter (in this case the 'a') from the character
// found, and thus get the position of the desired bit // found, and thus get the position of the desired bit
bits |= @as(u32, 1) << @truncate(u5, ascii.toLower(c) - 'a'); bits |= @as(u32, 1) << @truncate(u5, ascii.toLower(c) - 'a');
} }

@ -22,7 +22,7 @@
// These can be used in different ways, but typically to convert // These can be used in different ways, but typically to convert
// numerical values into various text representations. The // numerical values into various text representations. The
// results can be used for direct output to a terminal or stored // results can be used for direct output to a terminal or stored
// for later use or written to 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.
// //
// In Ziglings, we are concerned with the output to the console. // In Ziglings, we are concerned with the output to the console.

Loading…
Cancel
Save