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 reduce()
function.
reduce()
(or 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 itertools.groupby
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4