Introduction
The idea of functional programming is to focus on writing small, expressive functions that perform the required data transformations. Combining functions can often create code which is more succinct and expressive than long strings of procedural statements or the methods of complex, stateful objects. Python allows all three kinds of programming.
Conventional mathematics defines many things as functions. Multiple functions are combined to build up a complex result from previous transformations. For example, we might have two functions, f(x) and g(y), that need to be combined to create a useful result:
y = f(x)
z = g(y)
Ideally, we can create a composite function from these two functions:
z = (g ∘ f)(x)
Using a composite function, (g ∘ f), can help to clarify how a program works. It allows us to take a number of small details and combine them into a larger knowledge chunk.
Since programming often works with collections of data, we'll often be applying a function to a whole collection...