Functional programming is the way of computing using a series of functions. Functions are understood here in the mathematical sense, not in the sense of subroutines in Perl 6. A very important principle of functional programming is that functions must have no side effects. In particular, that means that variables must be immutable—assigning a new value is forbidden.
All the topics that we will discuss in this chapter are the consequences of the preceding restrictions. It is important to realize that, for example, lambda functions are not the core essence of functional programming but are just one of the ways of following the main principle of having no side effects, such is changing some global variables that affect the result of the function.
Let us take a function f($x) and call it twice with the same argument. Will the second call return...