0
Functional Programming
def apply_twice(func, arg): return func(func(arg)) def add_five(x): return x + 5 print(apply_twice(add_five, 10)) Can someone please explain how the above example returned an answer of 20?
3 Respostas
+ 1
Thank you Ali and Gordie! I understand it now!
0
apply_twice(add_five, 10)
does the same as
add_five(add_five(10))
So it adds 5 to 10 twice, which results in 20.