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()) Traceback (most recent call last): File "<ipython-input-28-5166a7a3086
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())
Traceback (most recent call last):
File "<ipython-input-28-5166a7a30861>", line 9, in <module>
print (f())
File "<ipython-input-28-5166a7a30861>", line 5, in lazy_prod
return reduce(f, lst, 1)
NameError: name 'reduce' is not defined