162. D.pieces(cuts:) is coordinate compression for intervals (2026-11-21)
- Decision.
r.pieces(cuts: cs)splits a range (a domain reads as its range) at the given cuts and binds a fresh domain of the pieces between them:let (domain P, piece) = Rail.pieces(cuts: ...), withpiece: [P]Range<D>.piece.covering(a..=b)is theRange<P>tilinga..=b, trapping if its ends are not among the cuts. - Why. The blind ioi05p2 dream wrote
Rail.pieces(cuts:)andPiece.covering(...). The port compressed the pointsaandb + 1and then rebuilt each piece's length and the range conversion with+1/-1arithmetic, the off-by-one class the language exists to remove. Inputs are cuts and pieces are ranges, so the positions/cuts split (chapter 04) carries the proof. The same shape covers union-of-rectangles sweeps and interval painting over huge coordinates. Ryan agreed it is worth having. - Reverse. Delete
piecesandcoveringfromspec/std/seq.cp, drop the paragraph in chapter 04, and restorecompressincorpus/problems/ioi05p2/spec.cp.