The reduce() Function: Overview
In this section, you’ll discover another basic of functional programming: how to use the
reduce() function to transform data structures.
We’ll take an example data set represented using an immutable data structure from the previous lessons in this course, and then we’ll create a reduced or derived output from that data using Python’s built-in
functools.reduce() in Python 3) is one of the functional programming primitives (or building blocks) available in Python. It’s useful in a number of contexts.
Later in this section, you’ll see how the
reduce() function lets you group your data set into arbitrary categories. You’ll also learn about Python’s
defaultdict class defined in the
collections module, as well as some useful helpers in the
itertools module, like
Comments & Discussion
Become a Member to join the conversation.