In this chapter, we got a new perspective when it comes to using C++. As a multi-paradigm language, it can be used as a functional programming language.
We learned the main principles of functional programming, such as pure functions, higher-order functions, and folding. Pure functions are functions that do not mutate the state. One of the pros of pure functions is that they leave fewer bugs that would otherwise be introduced because of state mutations.
Higher-order functions are functions that take or return other functions. Other than in functional programming, C++ programmers use higher-order functions when dealing with the STL.
Pure functions, along with higher-order functions, allow us to decompose the whole application into a big assembly line of functions. Each function in this assembly line is responsible for receiving data and returning a new, modified version...