September 2017
Beginner
402 pages
9h 52m
English
In the previous section, we were calculating the sum of the numbers between 10 and 15. The program, after some transformations, became equivalent to the following one:
say 10 + (11 + (12 + (13 + (14 + 15))));
Each pair of parentheses here corresponds to the recursive call of the sum function. Calls of the function are replaced here with its implementation. This is one of the consequences of the restriction of the state-less approach. Would the function depend on the program state, it would not be possible to replace the function call with its implementation without knowing the values reflecting the state at different moments.
As parentheses do not change any order of execution here, let's remove them:
say 10 + 11 + 12 + 13 ...