编程技巧:lambda与递归以下代码演示如何使用lambda来定义阶乘这一递归函数。C#
#include <functional>function<int(int)> factorial = [&](int x){return x == 0 ? 1 : x * factorial(x - 1);};int f5 = factorial(5); // f5 == 120