I'm struggling to figure out how do higher order functions work, more specifically folder functions. I ran it through pythontutor a couple of times, however I don't quite understand how to trace the code correctly.
def fold(op, f, n):
if n==0:
return f(0)
else:
return op(f(n), fold(op, f, n-1))
fold(lambda x,y:x-y, x, 4)