// Typed Lambda Calculus in C# using System; using System.Collections.Generic; public class lambdacalc { public static a I(a x) => x; // type of I is a -> a public static Func K(a x) => (b y) => x; // a->b->a public static Func,Func> S(Func> x) => (y) => (z) => x(z)(y(z)); //(a->b->c)->(a->b)->a->c public static Func ZERO(a x) => (y) => y; // KI a->b->b public static Func ONE(a x) => (b y) => x; // a->b->a public static Func> IFELSE(Func> c) => (x) => (y) => c(x)(y); // recursion must be defined as a separate constant in typed lamb. calc. public static a FIX(Func M) => M(FIX(M)); public static void Main() { Func i = S(K)(I); // choke! int t1 = IFELSE(ONE)(1)(2); int t2 = IFELSE(ZERO)(1)(2); Console.WriteLine(t1+" and "+t2); }//main } // C# is not the right language to do this with: need F#!