Functional Programming | Sololearn: Learn to code for FREE!

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?

4/23/2018 5:44:25 AM

Troy Kelley

3 Answers

New Answer

+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.