Last active
March 27, 2025 16:19
-
-
Save TheFox/84771747203b9d2854cef525a9a27ffb to your computer and use it in GitHub Desktop.
Zig Error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using Zig 0.14.0 | |
pub const Node = struct { | |
allocator: Allocator, | |
children: ArrayList(Node), | |
parent: ?*Node, | |
max_level: usize, | |
... | |
pub fn init(allocator: Allocator, value: u8, level: usize) Node { | |
const children = ArrayList(Node).init(allocator); | |
return Node{ | |
.allocator = allocator, | |
.children = children, | |
.parent = null, | |
.max_level = 0, | |
... | |
}; | |
} | |
pub fn reportLevel(self: *Node, max_level: usize) void { | |
print("reportLevel: {d} -> {d}\n", .{ self.level, max_level }); | |
self.max_level = max_level; | |
if (self.parent) |parent| { | |
print("Parent exists at: {*}---\n", .{parent}); | |
parent.reportLevel(max_level); | |
print("Parent exists OK\n", .{}); | |
} else { | |
print("No parent, stopping recursion.\n", .{}); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment