summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
Diffstat (limited to 'exercises')
-rw-r--r--exercises/076_sentinels.zig4
-rw-r--r--exercises/077_sentinels2.zig2
-rw-r--r--exercises/078_sentinels3.zig2
-rw-r--r--exercises/079_quoted_identifiers.zig8
-rw-r--r--exercises/080_anonymous_structs.zig4
-rw-r--r--exercises/081_anonymous_structs2.zig2
-rw-r--r--exercises/082_anonymous_structs3.zig8
-rw-r--r--exercises/083_anonymous_lists.zig2
-rw-r--r--exercises/084_interfaces.zig4
-rw-r--r--exercises/085_async.zig2
-rw-r--r--exercises/086_async2.zig2
-rw-r--r--exercises/087_async3.zig2
-rw-r--r--exercises/088_async4.zig2
-rw-r--r--exercises/089_async5.zig2
-rw-r--r--exercises/090_async6.zig2
15 files changed, 25 insertions, 23 deletions
diff --git a/exercises/076_sentinels.zig b/exercises/076_sentinels.zig
index accb600..3ba6bf8 100644
--- a/exercises/076_sentinels.zig
+++ b/exercises/076_sentinels.zig
@@ -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;
}
diff --git a/exercises/077_sentinels2.zig b/exercises/077_sentinels2.zig
index fb8f13d..c2fb54c 100644
--- a/exercises/077_sentinels2.zig
+++ b/exercises/077_sentinels2.zig
@@ -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..foo.length];
print("{s}\n", .{printable});
}
diff --git a/exercises/078_sentinels3.zig b/exercises/078_sentinels3.zig
index 1e443e6..90b953f 100644
--- a/exercises/078_sentinels3.zig
+++ b/exercises/078_sentinels3.zig
@@ -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});
}
diff --git a/exercises/079_quoted_identifiers.zig b/exercises/079_quoted_identifiers.zig
index 182c7ff..6abbe59 100644
--- a/exercises/079_quoted_identifiers.zig
+++ b/exercises/079_quoted_identifiers.zig
@@ -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",
});
}
diff --git a/exercises/080_anonymous_structs.zig b/exercises/080_anonymous_structs.zig
index 4e3ce84..b7d7641 100644
--- a/exercises/080_anonymous_structs.zig
+++ b/exercises/080_anonymous_structs.zig
@@ -48,13 +48,13 @@ pub fn main() void {
// * circle1 should hold i32 integers
// * circle2 should hold f32 floats
//
- const circle1 = ??? {
+ const circle1 = Circle(i32) {
.center_x = 25,
.center_y = 70,
.radius = 15,
};
- const circle2 = ??? {
+ const circle2 = Circle(f32) {
.center_x = 25.234,
.center_y = 70.999,
.radius = 15.714,
diff --git a/exercises/081_anonymous_structs2.zig b/exercises/081_anonymous_structs2.zig
index df78713..0b84438 100644
--- a/exercises/081_anonymous_structs2.zig
+++ b/exercises/081_anonymous_structs2.zig
@@ -38,7 +38,7 @@ pub fn main() void {
// Please complete this function which prints an anonymous struct
// representing a circle.
-fn printCircle(???) void {
+fn printCircle(circle: anytype) void {
print("x:{} y:{} radius:{}\n", .{
circle.center_x,
circle.center_y,
diff --git a/exercises/082_anonymous_structs3.zig b/exercises/082_anonymous_structs3.zig
index e99c826..5a971f5 100644
--- a/exercises/082_anonymous_structs3.zig
+++ b/exercises/082_anonymous_structs3.zig
@@ -82,17 +82,17 @@ fn printTuple(tuple: anytype) void {
// @typeInfo(Circle).@"struct".field_types
//
// This will be an array of field types.
- const field_types = ???;
+ const field_types = @typeInfo(@TypeOf(tuple)).@"struct".field_types;
// This will be an array of field names.
- const field_names = ???;
+ const field_names = @typeInfo(@TypeOf(tuple)).@"struct".field_names;
// 2. Loop through each field. This must be done at compile
// time.
//
// Hint: remember 'inline' loops?
//
- for (???, ???) |???, ???| {
+ inline for (field_types, field_names) |field_type, field_name| {
// 3. Print the field's name, type, and value.
//
// You'll need this builtin:
@@ -116,7 +116,7 @@ fn printTuple(tuple: anytype) void {
print("\"{s}\"({any}):{any} ", .{
field_name,
field_type,
- ???,
+ @field(tuple, field_name),
});
}
}
diff --git a/exercises/083_anonymous_lists.zig b/exercises/083_anonymous_lists.zig
index daaeaff..82d008a 100644
--- a/exercises/083_anonymous_lists.zig
+++ b/exercises/083_anonymous_lists.zig
@@ -20,6 +20,6 @@ pub fn main() void {
//
// = .{ 'h', 'e', 'l', 'l', 'o' };
//
- const hello = .{ 'h', 'e', 'l', 'l', 'o' };
+ const hello: [5]u8 = .{ 'h', 'e', 'l', 'l', 'o' };
print("I say {s}!\n", .{hello});
}
diff --git a/exercises/084_interfaces.zig b/exercises/084_interfaces.zig
index fd61ead..aaa4328 100644
--- a/exercises/084_interfaces.zig
+++ b/exercises/084_interfaces.zig
@@ -106,7 +106,9 @@ pub fn main() !void {
for (my_insects) |insect| {
// Almost done! We want to print() each insect with a
// single method call here.
- ???
+ switch (insect) {
+ inline else => |i| i.print(),
+ }
}
}
diff --git a/exercises/085_async.zig b/exercises/085_async.zig
index 1d885a5..d4f4a3f 100644
--- a/exercises/085_async.zig
+++ b/exercises/085_async.zig
@@ -38,7 +38,7 @@
const std = @import("std");
pub fn main(init: std.process.Init) !void {
- const io = init.???;
+ const io = init.io;
// Get the current wall-clock time using the Io interface.
// Hint: Timestamp.now() takes an Io and a Clock type (.real = wall clock).
diff --git a/exercises/086_async2.zig b/exercises/086_async2.zig
index cf376e2..89a061d 100644
--- a/exercises/086_async2.zig
+++ b/exercises/086_async2.zig
@@ -44,7 +44,7 @@ pub fn main(init: std.process.Init) !void {
// Now collect the result. What method on Future gives us
// the value, blocking until it's ready?
- const answer = future.???(io);
+ const answer = future.await(io);
print("The answer is: {}\n", .{answer});
}
diff --git a/exercises/087_async3.zig b/exercises/087_async3.zig
index d10052c..b4644d5 100644
--- a/exercises/087_async3.zig
+++ b/exercises/087_async3.zig
@@ -28,7 +28,7 @@ pub fn main(init: std.process.Init) !void {
// Launch both tasks asynchronously.
var future_a = io.async(slowAdd, .{ 1, 2 });
defer _ = future_a.cancel(io);
- var future_b = ???(slowMul, .{ 6, 7 });
+ var future_b = io.async(slowMul, .{ 6, 7 });
defer _ = future_b.cancel(io);
// Await both results.
diff --git a/exercises/088_async4.zig b/exercises/088_async4.zig
index 8298ca1..3091477 100644
--- a/exercises/088_async4.zig
+++ b/exercises/088_async4.zig
@@ -38,7 +38,7 @@ pub fn main(init: std.process.Init) !void {
// Wait for all tasks to finish.
// What Group method blocks until all tasks complete?
- try group.???(io);
+ try group.await(io);
print("All tasks finished!\n", .{});
}
diff --git a/exercises/089_async5.zig b/exercises/089_async5.zig
index 0c00c1f..c1ac0e4 100644
--- a/exercises/089_async5.zig
+++ b/exercises/089_async5.zig
@@ -46,7 +46,7 @@ pub fn main(init: std.process.Init) !void {
// We don't want to wait 10 seconds!
// Which Future method requests cancellation AND returns the result?
- const result = future.???(io);
+ const result = future.cancel(io);
print("Task returned: {}\n", .{result});
}
diff --git a/exercises/090_async6.zig b/exercises/090_async6.zig
index 16fb75f..b25e8b1 100644
--- a/exercises/090_async6.zig
+++ b/exercises/090_async6.zig
@@ -52,7 +52,7 @@ pub fn main(init: std.process.Init) !void {
// Wait for the first finisher.
// What Select method returns the first completed result?
- const winner = try sel.???();
+ const winner = try sel.await();
switch (winner) {
.hare => |msg| print("Hare: {s}\n", .{msg}),