利用lambda和条件表达式构造匿名递归函数

from operator import sub, mul                                             
 
def make_anonymous_factorial():
    """Return the value of an expression that computes factorial.

    >>> make_anonymous_factorial()(5)
    120
    """
    return (lambda f: lambda n: f(f, n))(lambda f, n: 1 if n == 1 else mul(n, f(f, sub(n, 1)))) 

原文地址:https://www.cnblogs.com/Willendless/p/10466208.html