Practice Python
import operator
def foldright(xs, f, base):
if xs == []:
return base
else:
return f(xs[0], foldright(xs[1:], f, base))
ret = foldright([1,2,3,4,5], operator.add, 0)
print(ret)INFO
import operator
def foldright(xs, f, base):
if xs == []:
return base
else:
return f(xs[0], foldright(xs[1:], f, base))
ret = foldright([1,2,3,4,5], operator.add, 0)
print(ret)