summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
Diffstat (limited to 'exercises')
-rw-r--r--exercises/019_functions2.zig2
-rw-r--r--exercises/026_hello2.zig4
-rw-r--r--exercises/034_quiz4.zig4
-rw-r--r--exercises/098_bit_manipulation2.zig4
-rw-r--r--exercises/104_threading.zig6
5 files changed, 10 insertions, 10 deletions
diff --git a/exercises/019_functions2.zig b/exercises/019_functions2.zig
index a527ae2..5a76c7b 100644
--- a/exercises/019_functions2.zig
+++ b/exercises/019_functions2.zig
@@ -3,7 +3,7 @@
// example that takes two parameters. As you can see, parameters
// are declared just like any other types ("name": "type"):
//
-// fn myFunction(number: u8, is_lucky: bool) {
+// fn myFunction(number: u8, is_lucky: bool) void {
// ...
// }
//
diff --git a/exercises/026_hello2.zig b/exercises/026_hello2.zig
index cd59b86..582dba9 100644
--- a/exercises/026_hello2.zig
+++ b/exercises/026_hello2.zig
@@ -16,12 +16,12 @@ const std = @import("std");
//
pub fn main() !void {
// We get a Writer for Standard Out so we can print() to it.
- const stdout = std.io.getStdOut().writer();
+ var stdout = std.fs.File.stdout().writer(&.{});
// Unlike std.debug.print(), the Standard Out writer can fail
// with an error. We don't care _what_ the error is, we want
// to be able to pass it up as a return value of main().
//
// We just learned of a single statement which can accomplish this.
- stdout.print("Hello world!\n", .{});
+ stdout.interface.print("Hello world!\n", .{});
}
diff --git a/exercises/034_quiz4.zig b/exercises/034_quiz4.zig
index 2d843f2..8704397 100644
--- a/exercises/034_quiz4.zig
+++ b/exercises/034_quiz4.zig
@@ -10,11 +10,11 @@ const std = @import("std");
const NumError = error{IllegalNumber};
pub fn main() void {
- const stdout = std.io.getStdOut().writer();
+ var stdout = std.fs.File.stdout().writer(&.{});
const my_num: u32 = getNumber();
- try stdout.print("my_num={}\n", .{my_num});
+ try stdout.interface.print("my_num={}\n", .{my_num});
}
// This function is obviously weird and non-functional. But you will not be changing it for this quiz.
diff --git a/exercises/098_bit_manipulation2.zig b/exercises/098_bit_manipulation2.zig
index 979b103..8b51265 100644
--- a/exercises/098_bit_manipulation2.zig
+++ b/exercises/098_bit_manipulation2.zig
@@ -32,7 +32,7 @@ const print = std.debug.print;
pub fn main() !void {
// let's check the pangram
- print("Is this a pangram? {?}!\n", .{isPangram("The quick brown fox jumps over the lazy dog.")});
+ print("Is this a pangram? {}!\n", .{isPangram("The quick brown fox jumps over the lazy dog.")});
}
fn isPangram(str: []const u8) bool {
@@ -45,7 +45,7 @@ fn isPangram(str: []const u8) bool {
// loop about all characters in the string
for (str) |c| {
// if the character is an alphabetical character
- if (ascii.isASCII(c) and ascii.isAlphabetic(c)) {
+ if (ascii.isAscii(c) and ascii.isAlphabetic(c)) {
// then we set the bit at the position
//
// to do this, we use a little trick:
diff --git a/exercises/104_threading.zig b/exercises/104_threading.zig
index 9c4e216..638769f 100644
--- a/exercises/104_threading.zig
+++ b/exercises/104_threading.zig
@@ -106,7 +106,7 @@ pub fn main() !void {
// After the threads have been started,
// they run in parallel and we can still do some work in between.
- std.time.sleep(1500 * std.time.ns_per_ms);
+ std.Thread.sleep(1500 * std.time.ns_per_ms);
std.debug.print("Some weird stuff, after starting the threads.\n", .{});
}
// After we have left the closed area, we wait until
@@ -117,12 +117,12 @@ pub fn main() !void {
// This function is started with every thread that we set up.
// In our example, we pass the number of the thread as a parameter.
fn thread_function(num: usize) !void {
- std.time.sleep(200 * num * std.time.ns_per_ms);
+ std.Thread.sleep(200 * num * std.time.ns_per_ms);
std.debug.print("thread {d}: {s}\n", .{ num, "started." });
// This timer simulates the work of the thread.
const work_time = 3 * ((5 - num % 3) - 2);
- std.time.sleep(work_time * std.time.ns_per_s);
+ std.Thread.sleep(work_time * std.time.ns_per_s);
std.debug.print("thread {d}: {s}\n", .{ num, "finished." });
}