0
What does this codes means?
2 Answers
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).
+ 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.