Created
March 29, 2019 01:14
-
-
Save infinnie/25689f4ea20d4d9430ebf7f6c320ffe5 to your computer and use it in GitHub Desktop.
Fixed Point Combinator in C#
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
using System; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
delegate T Out<T>(T x); | |
delegate Out<T> RecOut<T>(RecOut<T> x); | |
class YClass<T> | |
{ | |
public static Out<T> Y (Out<Out<T>> g) { | |
RecOut<T> callIt = x => x(x); | |
return callIt(x => y => g(x(x))(y)); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(YClass<int>.Y(f => x => x == 0 ? 1 : x * f(x - 1))(6)); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment