19th Nov 2019, 1:25 AM
Ansab Khan
Ansab Khan - avatar
2 Antworten
0
The code is an example of function composition: applying functions to functions. If you think of functions as a set of instructions, then function composition is doing one set of instructions after another, starting from the inner function. apply_twice is a function that composes a function with itself: i.e. it does the same set of instructions twice. It takes two arguments: a function (the set of instructions that will be done twice) and an argument (the thing that the instructions will be done on). For this example, the function that it takes in is add_five (our instructions) and the argument is 10. This means that apply_twice will add five twice to 10 (producing 20).
19th Nov 2019, 5:22 PM
Njeri
Njeri - avatar
+ 1
This is functional programming. In which we write function for different works and call these functions when we need it.In functional programming we also sometimes write function to call other functions.
19th Nov 2019, 2:37 AM
Maninder $ingh
Maninder $ingh - avatar