Last active
May 1, 2025 03:57
-
-
Save palladin/902e1e8814a36c00a7acaaeb03bcef8e to your computer and use it in GitHub Desktop.
Yet another dynamic Y combinator
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
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