5. Many to One: Reducing
Overview
In this chapter, you will learn new techniques for dealing with sequential data. You will learn how to use the reduce
function, as well as other reducing techniques that provide greater flexibility for transforming or extracting data from a sequence. We will use the simple form of reduce
, use reduce
with an initializer and an accumulator, and solve problems requiring a variable-length "window" over a sequence. We will also reduce sequences with functions other than reduce
.
By the end of this chapter, you will be able to use reduce
with complex accumulators.