Skip to content

Instantly share code, notes, and snippets.

@cryks
Created November 16, 2011 12:03
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 cryks/1369927 to your computer and use it in GitHub Desktop.
Save cryks/1369927 to your computer and use it in GitHub Desktop.
Y Combinator on C#
private delegate Func<A, R> Recursive<A, R>(Recursive<A, R> r);
public static Func<A, R> Y<A, R>(Func<Func<A, R>, Func<A, R>> f) {
return ((Recursive<A, R>)(r => a => f(r(r))(a)))((Recursive<A, R>)(r => a => f(r(r))(a)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment