Design decisions

95. xs.reach(while:, cyclic:) names the two-pointer sweep (2026-11-21)

  • Decision. Add reach(self, while: (T, T) -> Bool, cyclic: Bool = false) -> List<Int> to every sequence: for each i, the largest k such that while(xs[i], xs[i + j]) holds for every 1 <= j <= k (indices taken mod len and k < len when cyclic). Cost: O(n) calls of while when the reach drops by at most one from i to i + 1, which holds whenever while(a, ·) is true-then-false along a sorted order; debug builds trap when that is violated.
  • Why. The hand-written loop while j < i + m and p(xs[i], xs[j % m]): j += 1 with a j = max(j, i + 1) clamp appears in angular sweeps, circular arcs and distance windows (cf1284e and others), and a binary search per element costs a log factor. One method replaces the loop and states the quantity; it is not a cyclic-only helper, and cyclic_span is not added.
  • Reverse. Remove reach from std.seq; ports go back to explicit two pointers.