Compare commits

..

No commits in common. "main" and "v0.15.1" have entirely different histories.

9 changed files with 21 additions and 52 deletions

View File

@ -12,10 +12,10 @@ the current Zig snapshot, setup a copy of Ziglings, and knows
common language building blocks (if/then/else, loops, and
functions) is ready for Ziglings.
Zigling's excercises are self-contained. If you can't solve
an exercise from the information you've gleaned so far from
Ziglings, then the exercise probably needs some additional work.
Please file an issue!
Ziglings is intended to be completely self-contained. If you
can't solve an exercise from the information you've gleaned so
far from Ziglings, then the exercise probably needs some
additional work. Please file an issue!
If an example doesn't match a description or if something is
unclear, please file an issue!
@ -52,8 +52,6 @@ If you run into an error in Ziglings caused by breaking changes
in the latest development build of Zig, that's a new bug in
Ziglings. Please file an issue...or make a pull request!
For the latter, also read "The Secrets” section.
## Formatting
@ -91,23 +89,3 @@ contribution for any other purpose.
If you want to peek at the secrets, take a look at the `patches/`
directory.
Every Ziglings exercise contains mistakes on purpose.
To keep our automated tests happy, each exercise also
has a patch in `patches/healed` that “heals” it.
When you change an exercise, you will usually need to update
its patch too. Thats where our little helper Gollum comes in:
1. In the project root, create a folder called `answers/`
2. Put your solved version of the exercise file in there
3. Back in the root, run:
`./patches/gollum <exercise-number>`<br>
For example: `./patches/gollum 106`
This will generate a shiny new patch.
Double-check everything by asking the magical Eowyn:
`./patches/eowyn`<br>
If all tests pass: You are done!
Dont forget to commit the patch file.

View File

@ -25,9 +25,10 @@ language such as C.
Each exercise is self-contained and self-explained. However,
you're encouraged to also check out these Zig language resources
for more details:
for more detail:
* https://ziglang.org/learn/
* https://ziglearn.org/
* https://ziglang.org/documentation/master/
* [Zig in Depth! (video series)](https://www.youtube.com/watch?v=MMtvGA1YhW4&list=PLtB7CL7EG7pCw7Xy1SQC53Gl8pI7aDg9t&pp=iAQB)
@ -44,7 +45,7 @@ Verify the installation and build number of `zig` like so:
```
$ zig version
0.16.0-dev.xxxx+xxxxxxxxx
0.15.0-dev.xxxx+xxxxxxxxx
```
Clone this repository with Git:
@ -72,8 +73,8 @@ the appropriate tag.
The Zig language is under very active development. In order to be
current, Ziglings tracks **development** builds of the Zig
compiler rather than versioned **release** builds. The last
stable release was `0.15.1`, but Ziglings needs a dev build with
pre-release version "0.16.0" and a build number at least as high
stable release was `0.14.1`, but Ziglings needs a dev build with
pre-release version "0.15.0" and a build number at least as high
as that shown in the example version check above.
It is likely that you'll download a build which is _greater_ than
@ -86,7 +87,6 @@ that if you update one, you may need to also update the other.
### Version Changes
* *2025-09-03* zig 0.16.0-dev.164 - changes in reader, see [#25077](https://github.com/ziglang/zig/pull/25077)
* *2025-08-15* zig 0.15.0-dev.1519 - changes in array list, see [#24801](https://github.com/ziglang/zig/pull/24801)
* *2025-08-08* zig 0.15.0-dev.1380 - changes in build system, see [#24588](https://github.com/ziglang/zig/pull/24588)
* *2025-07-22* zig 0.15.0-dev.1092 - various changes due to new I/O API, see [#24488](https://github.com/ziglang/zig/pull/24488)

View File

@ -15,7 +15,7 @@ const print = std.debug.print;
// 1) Getting Started
// 2) Version Changes
comptime {
const required_zig = "0.16.0-dev.164";
const required_zig = "0.15.0-dev.1519";
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable;
if (current_zig.order(min_zig) == .lt) {
@ -276,12 +276,8 @@ pub fn build(b: *Build) !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const contents = try allocator.alloc(u8, progress_file_size);
const contents = try progress_file.readToEndAlloc(allocator, progress_file_size);
defer allocator.free(contents);
const bytes_read = try progress_file.read(contents);
if (bytes_read != progress_file_size) {
return error.UnexpectedEOF;
}
starting_exercise = try std.fmt.parseInt(u32, contents, 10);
} else |err| {
@ -512,10 +508,6 @@ const ZiglingStep = struct {
zig_args.append("-lc") catch @panic("OOM");
}
if (b.reference_trace) |rt| {
zig_args.append(b.fmt("-freference-trace={}", .{rt})) catch @panic("OOM");
}
zig_args.append(b.pathFromRoot(path)) catch @panic("OOM");
zig_args.append("--cache-dir") catch @panic("OOM");
@ -570,7 +562,7 @@ const ZiglingStep = struct {
// Render compile errors at the bottom of the terminal.
// TODO: use the same ttyconf from the builder.
const ttyconf: std.Io.tty.Config = if (use_color_escapes)
const ttyconf: std.io.tty.Config = if (use_color_escapes)
.escape_codes
else
.no_color;

View File

@ -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) void {
// fn myFunction(number: u8, is_lucky: bool) {
// ...
// }
//

View File

@ -58,7 +58,7 @@ test "add" {
// Another way to perform this test
// is as follows:
try testing.expectEqual(42, add(41, 1));
try testing.expectEqual(add(41, 1), 42);
// This time a test with the addition
// of a negative number:

View File

@ -63,9 +63,8 @@ pub fn main() !void {
}
// to check if you actually write to the file, you can either,
// 1. open the file in your text editor, or
// 2. print the content of the file in the console with one of these commands
// Linux/macOS: >> cat ./output/zigling.txt
// Windows (CMD): >> type .\output\zigling.txt
// 2. print the content of the file in the console with the following command
// >> cat ./output/zigling.txt
//
//
// More on Creating files

View File

@ -2,7 +2,7 @@
// Prerequisite :
// - exercise/106_files.zig, or
// - create a file {project_root}/output/zigling.txt
// with content `It's zigling time!`(18 bytes total)
// with content `It's zigling time!`(18 byte total)
//
// Now there's no point in writing to a file if we don't read from it, am I right?
// Let's write a program to read the content of the file that we just created.

View File

@ -1,5 +1,5 @@
--- exercises/106_files.zig 2025-08-24 19:23:55.168565003 +0200
+++ answers/106_files.zig 2025-08-24 19:25:37.745597511 +0200
--- exercises/106_files.zig 2025-03-13 15:26:59.532367792 +0200
+++ answers/106_files.zig 2025-03-14 22:04:52.243435159 +0200
@@ -35,7 +35,7 @@
// by doing nothing
//

View File

@ -1,5 +1,5 @@
--- exercises/107_files2.zig 2025-08-24 19:15:17.789371332 +0200
+++ answers/107_files2.zig 2025-08-24 19:17:58.897538288 +0200
--- exercises/107_files2.zig 2025-03-13 15:26:59.532367792 +0200
+++ answers/107_files2.zig 2025-03-14 22:08:35.167953736 +0200
@@ -33,7 +33,7 @@
// initialize an array of u8 with all letter 'A'
// we need to pick the size of the array, 64 seems like a good number