Created
April 11, 2023 17:26
-
-
Save CraigglesO/4e38cbcd15d427a0d10a31e42253213e to your computer and use it in GitHub Desktop.
Non working solution to the man boy problem in zig
This file contains 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
const std = @import("std"); | |
const Func = *const fn () i32; | |
fn x (comptime n: i32) Func { | |
return struct { | |
fn lambda() i32 { return n; } | |
}.lambda; | |
} | |
inline fn a ( | |
comptime k: i32, | |
comptime x1: Func, | |
comptime x2: Func, | |
comptime x3: Func, | |
comptime x4: Func, | |
comptime x5: Func | |
) i32 { | |
const b = struct { | |
fn lambda() i32 { | |
return a(k - 1, &lambda, x1, x2, x3, x4); | |
} | |
}.lambda; | |
if (k > 0) { return b(); } | |
else { return x4() + x5(); } | |
} | |
pub fn main () !void { | |
std.debug.print("{}", .{a(0, x(1), x(-1), x(-1), x(1), x(0))}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment