using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class CurryingExtensions
{
public static Func<A, Func<B, R>> myExt<A, B, R>(this Func<A, B, R> f)
{
return a => b => f(a, b);
}
}
class MainClass
{
static void Main()
{
Func<int, int, int> adder = (x, y) => (x + y);
Func<int, Func<int, int>> c = adder.myExt();
Func<int, int> addsTwo = c(2);
Console.WriteLine(addsTwo(5));
}
}
|