aboutsummaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorManlio Perillo <[email protected]>2023-04-16 12:23:10 +0200
committerManlio Perillo <[email protected]>2023-04-18 18:16:19 +0200
commit6b17a188936d489e2777e541c84112b2609532d5 (patch)
tree99303fde89f0b921f44705433b7fc1a39d0b6fef /exercises
parentb59bef29b9c74270539e2f775d2f0394ec435f2d (diff)
downloadziglings-6b17a188936d489e2777e541c84112b2609532d5.tar.xz
ziglings-6b17a188936d489e2777e541c84112b2609532d5.zip
Ensure the exercises use the canonical format
Add the check-exercises.py tool in the new tools directory. It is used to check that the exercises are correctly formatted, printing on stderr the invalid ones and the diff in the unified format. Update the exercises that don't use the canonical zig fmt format. Update some patches that cause the generated zig file to be incorrectly formatted.
Diffstat (limited to 'exercises')
-rw-r--r--exercises/058_quiz7.zig28
-rw-r--r--exercises/059_integers.zig6
-rw-r--r--exercises/069_comptime4.zig2
-rw-r--r--exercises/075_quiz8.zig4
-rw-r--r--exercises/083_anonymous_lists.zig4
-rw-r--r--exercises/092_interfaces.zig2
6 files changed, 23 insertions, 23 deletions
diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig
index 3069710..1ceac5a 100644
--- a/exercises/058_quiz7.zig
+++ b/exercises/058_quiz7.zig
@@ -107,7 +107,7 @@ const Path = struct {
const a_paths = [_]Path{
Path{
.from = &a, // from: Archer's Point
- .to = &b, // to: Bridge
+ .to = &b, // to: Bridge
.dist = 2,
},
};
@@ -115,12 +115,12 @@ const a_paths = [_]Path{
const b_paths = [_]Path{
Path{
.from = &b, // from: Bridge
- .to = &a, // to: Archer's Point
+ .to = &a, // to: Archer's Point
.dist = 2,
},
Path{
.from = &b, // from: Bridge
- .to = &d, // to: Dogwood Grove
+ .to = &d, // to: Dogwood Grove
.dist = 1,
},
};
@@ -128,12 +128,12 @@ const b_paths = [_]Path{
const c_paths = [_]Path{
Path{
.from = &c, // from: Cottage
- .to = &d, // to: Dogwood Grove
+ .to = &d, // to: Dogwood Grove
.dist = 3,
},
Path{
.from = &c, // from: Cottage
- .to = &e, // to: East Pond
+ .to = &e, // to: East Pond
.dist = 2,
},
};
@@ -141,17 +141,17 @@ const c_paths = [_]Path{
const d_paths = [_]Path{
Path{
.from = &d, // from: Dogwood Grove
- .to = &b, // to: Bridge
+ .to = &b, // to: Bridge
.dist = 1,
},
Path{
.from = &d, // from: Dogwood Grove
- .to = &c, // to: Cottage
+ .to = &c, // to: Cottage
.dist = 3,
},
Path{
.from = &d, // from: Dogwood Grove
- .to = &f, // to: Fox Pond
+ .to = &f, // to: Fox Pond
.dist = 7,
},
};
@@ -159,20 +159,20 @@ const d_paths = [_]Path{
const e_paths = [_]Path{
Path{
.from = &e, // from: East Pond
- .to = &c, // to: Cottage
+ .to = &c, // to: Cottage
.dist = 2,
},
Path{
.from = &e, // from: East Pond
- .to = &f, // to: Fox Pond
- .dist = 1, // (one-way down a short waterfall!)
+ .to = &f, // to: Fox Pond
+ .dist = 1, // (one-way down a short waterfall!)
},
};
const f_paths = [_]Path{
Path{
.from = &f, // from: Fox Pond
- .to = &d, // to: Dogwood Grove
+ .to = &d, // to: Dogwood Grove
.dist = 7,
},
};
@@ -355,8 +355,8 @@ pub fn main() void {
// Here's where the hermit decides where he would like to go. Once
// you get the program working, try some different Places on the
// map!
- const start = &a; // Archer's Point
- const destination = &f; // Fox Pond
+ const start = &a; // Archer's Point
+ const destination = &f; // Fox Pond
// Store each Path array as a slice in each Place. As mentioned
// above, we needed to delay making these references to avoid
diff --git a/exercises/059_integers.zig b/exercises/059_integers.zig
index 5a6295d..a497efa 100644
--- a/exercises/059_integers.zig
+++ b/exercises/059_integers.zig
@@ -18,10 +18,10 @@
const print = @import("std").debug.print;
pub fn main() void {
- var zig = [_]u8 {
- 0o131, // octal
+ var zig = [_]u8{
+ 0o131, // octal
0b1101000, // binary
- 0x66, // hex
+ 0x66, // hex
};
print("{s} is cool.\n", .{zig});
diff --git a/exercises/069_comptime4.zig b/exercises/069_comptime4.zig
index 004a42c..f4c8bbb 100644
--- a/exercises/069_comptime4.zig
+++ b/exercises/069_comptime4.zig
@@ -16,7 +16,7 @@ const print = @import("std").debug.print;
pub fn main() void {
// Here we declare arrays of three different types and sizes
// at compile time from a function call. Neat!
- const s1 = makeSequence(u8, 3); // creates a [3]u8
+ const s1 = makeSequence(u8, 3); // creates a [3]u8
const s2 = makeSequence(u32, 5); // creates a [5]u32
const s3 = makeSequence(i64, 7); // creates a [7]i64
diff --git a/exercises/075_quiz8.zig b/exercises/075_quiz8.zig
index c2dbc1a..d54864c 100644
--- a/exercises/075_quiz8.zig
+++ b/exercises/075_quiz8.zig
@@ -151,8 +151,8 @@ const HermitsNotebook = struct {
};
pub fn main() void {
- const start = &a; // Archer's Point
- const destination = &f; // Fox Pond
+ const start = &a; // Archer's Point
+ const destination = &f; // Fox Pond
// We could either have this:
//
diff --git a/exercises/083_anonymous_lists.zig b/exercises/083_anonymous_lists.zig
index 838d40e..daaeaff 100644
--- a/exercises/083_anonymous_lists.zig
+++ b/exercises/083_anonymous_lists.zig
@@ -18,8 +18,8 @@ pub fn main() void {
//
// Don't change this part:
//
- // = .{'h', 'e', 'l', 'l', 'o'};
+ // = .{ 'h', 'e', 'l', 'l', 'o' };
//
- const hello = .{'h', 'e', 'l', 'l', 'o'};
+ const hello = .{ 'h', 'e', 'l', 'l', 'o' };
print("I say {s}!\n", .{hello});
}
diff --git a/exercises/092_interfaces.zig b/exercises/092_interfaces.zig
index 43f1119..5ac5768 100644
--- a/exercises/092_interfaces.zig
+++ b/exercises/092_interfaces.zig
@@ -99,7 +99,7 @@ pub fn main() !void {
var my_insects = [_]Insect{
Insect{ .ant = Ant{ .still_alive = true } },
Insect{ .bee = Bee{ .flowers_visited = 17 } },
- Insect{ .grasshopper = Grasshopper{ .distance_hopped = 32 }, },
+ Insect{ .grasshopper = Grasshopper{ .distance_hopped = 32 } },
};
std.debug.print("Daily Insect Report:\n", .{});