- Python iterators are mutable
- Haskell lists are immutable
Python iterators and Haskell lists are different things. We have not yet had to reckon with this fact, but for this lesson we can no longer look past the distinction.
Python iterators are mutable
First we’ll set up an example to illustrate why
itertools.tee exists. Let’s say we start with an iterator that represents all of the natural numbers starting from 1: