9 Itertools for Combinatorics – Permutations and Combinations
Functional programming emphasizes stateless algorithms. In Python, this leads us to work with generator expressions, generator functions, and iterables. In this chapter, we’ll continue our study of the itertools
library, with numerous functions to help us work with iterable collections.
In the previous chapter, we looked at three broad groupings of iterator functions. They are as follows:
Functions that work with infinite iterators, which can be applied to any iterable or an iterator over any collection; they consume the entire source
Functions that work with finite iterators, which can either accumulate a source multiple times, or produce a reduction of the source
The
tee()
iterator ...
Get Functional Python Programming - Third Edition 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.