Lambda Expression
public delegate Func<T, R> SFunc<T, R>(SFunc<T, R> v);public delegate Func<T, R> TFunc<T, R>(Func<T, R> v);
public delegate Func<T, R> YFunc<T, R>(TFunc<T, R> v);
static class util<T, R>
{
public static readonly TFunc<T, R> ConvF = f => x => f(x);
}
Console.WriteLine(
util<SFunc<int, int>, YFunc<int, int>>.ConvF
(h => f => h(g => f(x => g(g)(x))))
(f => f(f))
(f => n => (n <= 1) ? 1 : n * f(n - 1))
(10)
);这段简短代码集中了许多C#里应用Lambda Expression的技巧。请仔细体会。
问题:请写出最后那个Lambda表达式里面各个变量的类型。注意,同名的变量在不同的位置可能有不同的类型。
[ 本帖最后由 earthengine 于 22-11-2010 17:27 编辑 ]
页:
[1]