哪里错呢?程序1和程序2的区别?(小白一个,别介)
程序1:
def calc_prod(lst):
def g(x,y):
return x*y
return reduce(g,lst)
f = calc_prod([1, 2, 3, 4])
print f()
程序2: def calc_prod(lst): def lazy_prod(): def f(x, y): return x * y return reduce(f, lst, 1) return lazy_prod f = calc_prod([1, 2, 3, 4]) print f()