Skip to content

Instantly share code, notes, and snippets.

@palladin
Last active May 1, 2025 03:57
Show Gist options
  • Save palladin/902e1e8814a36c00a7acaaeb03bcef8e to your computer and use it in GitHub Desktop.
Save palladin/902e1e8814a36c00a7acaaeb03bcef8e to your computer and use it in GitHub Desktop.
Yet another dynamic Y combinator
delegate dynamic D(dynamic d);
static async Task Main()
{
Func<D, D> selfApp = f => f(f);
var Y = (Func<D, D> f) => selfApp(g => f(x => g(g)(x)));
Func<D, D> fact = (D f) => n => n <= 1 ? 1 : n * f(n - 1);
Console.WriteLine(Y(fact)(5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment