RangeChunk

typesince v1.10.514Edit
satisfies IChunk ICounted IIndexed ISeq

(RangeChunk. start step count)

Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(deftype RangeChunk [start step count]
  ICounted
  (-count [coll] count)

  ISeq
  (-first [coll] start)

  IIndexed
  (-nth [coll i]
    (+ start (* i step)))
  (-nth [coll i not-found]
    (if (and (>= i 0) (< i count))
      (+ start (* i step))
      not-found))

  IChunk
  (-drop-first [coll]
    (if (<= count 1)
      (throw (js/Error. "-drop-first of empty chunk"))
      (RangeChunk. (+ start step) step (dec count)))))