In this lesson
- It starts with a question. Mere writes two tiny functions. double(n) gives back n * 2. add_three(n) gives back n + 3. What does add_three(double(4)) give?
- The idea you will find. The inside call runs first, and its answer becomes the next input. — You got 11 one way and 14 the other, using the same two functions. The machine always finishes the innermost call, then passes what came back to the function wrapped around it. This is how big programs are built: small functions that each do one job, joined so the output of one is the input of the next.
- How you learn it. By doing: a slider, putting things in order.
- Length. 6 short steps. Progress saves on this phone.
Part of Reusable Code: Functions
Packaging a piece of work under a name so it can be reused and trusted.