A pure function computes each result from its inputs without retaining state between invocations. Stream API functions used by map() must be stateless; relying on encounter order or a previous element violates that contract. section 9.5
A stateful adjacent-element mapper
This pairMap implementation stores prev and started inside a Function, then maps and skips the first result. It may appear to work sequentially, but parallel execution can invoke the function in an order the stored state cannot safely represent. section 9.5
Avoid the mistake by:
- Following the Stream API contract even when callers control later operations. section 9.5
- Testing stream-consuming or stream-producing utilities after applying parallel(). section 9.5
- Using StreamEx for pairwise mapping when a dependency is acceptable, or avoiding Stream API for problems it cannot express idiomatically. section 9.5


















