function | since v0.0-927 | clojure.core/range | Edit |
(range)
(range end)
(range start end)
(range start end step)
Returns a lazy sequence of nums from start
(inclusive) to end
(exclusive),
by step
, where start
defaults to 0, step
to 1, and end
to infinity.
Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity.
(defn range
([] (range 0 (.-MAX_VALUE js/Number) 1))
([end] (range 0 end 1))
([start end] (range start end 1))
([start end step]
(cond
(pos? step)
(if (<= end start)
()
(if (and (integer? start) (integer? end) (integer? step))
(IntegerRange. nil start end step (range-count start end step) nil)
(Range. nil start end step nil nil nil)))
(neg? step)
(if (>= end start)
()
(if (and (integer? start) (integer? end) (integer? step))
(IntegerRange. nil start end step (range-count start end step) nil)
(Range. nil start end step nil nil nil)))
:else
(if (== end start)
()
(repeat start)))))