Chapter 5. Accumulation operations with reduce

 

This chapter covers

  • Recognizing the reduce pattern for N-to-X data transformations
  • Writing helper functions for reductions
  • Writing lambda functions for simple reductions
  • Using reduce to summarize data

In chapter 2, we learned about the first part of the map and reduce style of programming: map. In this chapter, we introduce the second part: reduce. As we noted in chapter 2, map performs N-to-N transformations. That is, if we have a situation where we want to take a sequence and get a same-sized sequence back, map is our go-to function. Among the examples of this that we’ve reviewed are file processing (we have a list of files and we want to do something to all of them; discussed in chapter 4) and web scraping (we have a list of websites and we want to get the content for each of them; discussed in chapter 2).

5.1. N-to-X with reduce

5.2. The three parts of reduce

5.3. Reductions you’re familiar with

5.4. Using map and reduce together

5.5. Analyzing car trends with reduce

5.6. Speeding up map and reduce

5.7. Exercises

Summary

sitemap