This chapter is on what I call fold-vectorization. In some languages, it’s called reduce, though the concept is the same. Fold implements binary iterated function application, where elements of a sequence are passed along with an accumulator to a function. This process repeats such that each successive element is paired with the previous result of the function application. The version of fold discussed in the book appears in my lambda.tools package.

There are numerous applications of fold that span basic algebraic functions, such as the cumulative sum and product, to applying the derivative, to implementing Markov Chains. This chapter first delves into the mathematical motivation for fold. It then returns to the ebola.sitrep package and discusses the use of fold for applying transformations to data frames. Some examples work off the parsed file, which resides in the data directory of the project. The chapter finishes up by reviewing some methods of numerical analysis related to function approximation and series to further illustrate the use of fold in implementing mathematical relationships.

As usual, feedback and comments are welcome. I’m mostly interested in conceptual issues, although grammatical and typographical issues are also fair game.

Rowe – Modeling Data With Functional Programming Chs1-4