mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-11-08 03:10:47 -05:00
075-079 completed
This commit is contained in:
parent
f86b769f62
commit
0651d71c47
5 changed files with 13 additions and 9 deletions
|
@ -49,7 +49,11 @@ const Path = struct {
|
|||
//
|
||||
// Please fill in the body of this function!
|
||||
fn makePath(from: *Place, to: *Place, dist: u8) Path {
|
||||
|
||||
return Path{
|
||||
.from = from,
|
||||
.to = to,
|
||||
.dist = dist,
|
||||
};
|
||||
}
|
||||
|
||||
// Using our new function, these path definitions take up considerably less
|
||||
|
|
|
@ -82,7 +82,7 @@ fn printSequence(my_seq: anytype) void {
|
|||
print("Array:", .{});
|
||||
|
||||
// Loop through the items in my_seq.
|
||||
for (???) |s| {
|
||||
for (my_seq) |s| {
|
||||
print("{}", .{s});
|
||||
}
|
||||
},
|
||||
|
@ -94,7 +94,7 @@ fn printSequence(my_seq: anytype) void {
|
|||
// Loop through the items in my_seq until we hit the
|
||||
// sentinel value.
|
||||
var i: usize = 0;
|
||||
while (??? != my_sentinel) {
|
||||
while (my_seq[i] != my_sentinel) {
|
||||
print("{}", .{my_seq[i]});
|
||||
i += 1;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ pub fn main() void {
|
|||
// length... You've actually solved this problem before!
|
||||
//
|
||||
// Here's a big hint: do you remember how to take a slice?
|
||||
const printable = ???;
|
||||
const printable = foo.data[0..11];
|
||||
|
||||
print("{s}\n", .{printable});
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn main() void {
|
|||
const data: [*]const u8 = "Weird Data!";
|
||||
|
||||
// Please cast 'data' to 'printable':
|
||||
const printable: [*:0]const u8 = ???;
|
||||
const printable: [*:0]const u8 = @ptrCast(data);
|
||||
|
||||
print("{s}\n", .{printable});
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
const 55_cows: i32 = 55;
|
||||
const isn't true: bool = false;
|
||||
const @"55_cows": i32 = 55;
|
||||
const @"isn't true": bool = false;
|
||||
|
||||
print("Sweet freedom: {}, {}.\n", .{
|
||||
55_cows,
|
||||
isn't true,
|
||||
@"55_cows",
|
||||
@"isn't true",
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue