chickadee » srfi-196 » range-segment

range-segment range lengthprocedure

Returns a list of ranges representing the consecutive subranges of length length. The last range is allowed to be shorter than length. The procedure runs in O(k) time, where k is the number of ranges returned. The average accessing time of the ranges is asymptotically bounded by the average accessing time of range.

Examples:

(map range->list (range-segment (numeric-range 0 12) 4))
  ⇒ ((0 1 2 3) (4 5 6 7) (8 9 10 11))

(map range->list (range-segment (numeric-range 0 2 1/3) 4))
  ⇒ ((0 1/3 2/3 1) (4/3 5/3))