summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2026-04-12 17:28:37 +0200
committerChris Boesch <chrboesch@noreply.codeberg.org>2026-04-12 17:28:37 +0200
commit8e055fcd187b333c9ed4fa794ac153ed10748a65 (patch)
tree6ddfb7595700feccda672cd859ed077a3c06b258 /patches
parentb225538aed949c50559e37f137663008539fcdee (diff)
parent2472caa18377d36d68c5c5b5989726d2df783866 (diff)
Merge pull request 'Replace exercise 074_comptime9' (#391) from tjk/ziglings-exercises:comptime9 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/391
Diffstat (limited to 'patches')
-rw-r--r--patches/patches/074_comptime9.patch42
1 files changed, 33 insertions, 9 deletions
diff --git a/patches/patches/074_comptime9.patch b/patches/patches/074_comptime9.patch
index 250d003..44a1709 100644
--- a/patches/patches/074_comptime9.patch
+++ b/patches/patches/074_comptime9.patch
@@ -1,11 +1,35 @@
---- exercises/074_comptime9.zig 2023-10-03 22:15:22.125574535 +0200
-+++ answers/074_comptime9.zig 2023-10-05 20:04:07.176102462 +0200
-@@ -39,7 +39,7 @@
+--- exercises/074_comptime9.zig 2026-04-11 21:35:08.132459373 -0700
++++ answers/074_comptime9.zig 2026-04-12 07:13:37.971010827 -0700
+@@ -27,12 +27,12 @@
+ start, // Ready to start a new animal.
+ l, // This means we've seen an "l", so if we see an "m", we know it's a Llama.
+ };
+- var state = State.start;
++ comptime var state = State.start;
- // And here's the function. Note that the return value type
- // depends on one of the input arguments!
--fn makeLlamas(count: usize) [count]u8 {
-+fn makeLlamas(comptime count: usize) [count]u8 {
- var temp: [count]u8 = undefined;
- var i = 0;
+ // We return an array of animals representing the creature. (This is why we
+ // really needed the 'count' parameter. Arrays need a size.)
+ var animals: [count]Animal = .{undefined} ** count;
+- var next_animal: usize = 0;
++ comptime var next_animal: usize = 0;
+ inline for (fmt) |char| {
+
+@@ -56,7 +56,7 @@
+ //
+ // What do you think happens with Gators? Do they join with
+ // other animals or is this an error?
+- 'g' => ???,
++ 'g' => @compileError("Gators refuse to join with other animals."),
+
+ else => @compileError("No animal starts with '" ++ char ++ "'!"),
+ },
+@@ -68,7 +68,7 @@
+ next_animal += 1;
+ // Something is missing here. After we finish a Llama, we
+ // need to be ready to _start_ over with a new animal...
+- ???
++ state = .start;
+ },
+
+ else => @compileError("Only llamas start with 'l'!"),