Implement an iterator library: range(start, end, step=
-
supporting forward/backward iteration, inclusive/exclusive endpoints, negative steps, and overflow-safe termination. Provide lazy combinators map, filter, zip, take(n), drop(n), and chain, each with O(
-
extra space and amortized O(
-
per element. Add a PeekableIterator with peek() and hasNext(); discuss whether and how reset()/rewind() can be supported without materializing the sequence. Define iterator invalidation rules when the underlying collection changes. Write unit tests for boundary cases (very large ranges, zero step, empty ranges, negative steps) and demonstrate usage in your preferred language.