chickadee » srfi-196 » range-take-while-right

range-take-while-right pred rangeprocedure

Returns a range containing the leading/trailing elements of range that satisfy pred up to the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).

Examples:

(range->list (range-take-while (lambda (x) (< x 10))
                               (numeric-range 5 15)))
  ⇒ (5 6 7 8 9)

(range->list (range-take-while-right (lambda (x) (> x 10))
                                     (numeric-range 5 15)))
  ⇒ (11 12 13 14)