using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
delegate T id<T>(T arg0);
static id<T> Y<T>(id<id<T>> f)
{
return x => f(Y(f))(x);
}
static id<id<T>> _<T>(id<id<T>> f) { return f; }
public static void Main(string[] args)
{
var fib = _<int>(f => n => n < 3 ? n : f(n - 1) + f(n - 2));
Console.WriteLine(Y(fib)(5));
}
}
}
|