12 Functional iteration


In this chapter

  • Learn the three functional tools, map(), filter(), and reduce().
  • Discover how to replace simple for loops over arrays with the functional tools.
  • Derive implementations for the three functional tools.

Many functional languages come with a variety of powerful, abstract functions for dealing with collections of data. In this chapter, we’re going to focus on three very common ones, namely map(), filter(), and reduce(). These tools form the backbones of many functional programs. They replace for loops as the workhorse of the functional programmer. Since looping over arrays is something we do a lot, these ...

Get Grokking Simplicity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.