using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class DoubleApplicationExtensions
{
public static Func<T, T> ApplyTwice<T>(this Func<T, T> original)
{
return x => original(original(x));
}
}
class MainClass
{
static void Main()
{
Func<int, int> incrementer = x => x + x;
Func<int, int> doubleIncrementer = incrementer.ApplyTwice();
Console.WriteLine(doubleIncrementer(5));
}
}
|