Skip to content

Instantly share code, notes, and snippets.

@CraigglesO
Created April 11, 2023 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CraigglesO/4e38cbcd15d427a0d10a31e42253213e to your computer and use it in GitHub Desktop.
Save CraigglesO/4e38cbcd15d427a0d10a31e42253213e to your computer and use it in GitHub Desktop.
Non working solution to the man boy problem in zig
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