日期:2014-05-17 浏览次数:20922 次
Func<int, Func<int, int>> add = x => new Func<int, int>(y => x + y);
int i = add(3)(4);
Console.WriteLine(i);
Func<int, int> addTen = x => add(10)(x);
int j = addTen(i);
Console.WriteLine(j);
Func<int, Func<Func<int, Func<int, int>>, Func<int, int>>> eval =
x => new Func<Func<int, Func<int, int>>, Func<int, int>>(
y => new Func<int, int>(z => y(x)(z)));
Func<int, Func<int, int>> add = x => new Func<int, int>(y => x + y);
int i = eval(3)(add)(5);
Console.WriteLine(i);
Func<int, Func<int, int>> sub = x => new Func<int, int>(y => x - y);
i = eval(i)(sub)(1);
Func<Action<int>, Action<int[]>> iter = new Func<Action<int>,Action<int[]>>
(x => new Action<int[]>(y => { foreach (int i in y) x(i); }));
var OutputArray = iter(x => Console.WriteLine(x));
int[] data = { 1, 2, 3, 4, 5 };
OutputArray(data);