is there a build-in equivalent of such function in python:
def foo(a_func,a_list):
if len(a_list)==2:
return a_func(*[a_list])
else:
return a_func(a_list[0],foo(a_func,a_list[0:]))
in other words foo(lambda x,y:x+y,[1,2,3,4]) would add 1+2+3+4
and foo(lambda x,y:x-y,[1,2,3,4]) would do ((1-2)-3)-4 etc.
And i know you can make it faster and prevent stack overflow ( :D ) but i think i remember such function but have no idea what the name is and dunno what to google.