user=> (take 5 (cycle ["a" "b"])) ("a" "b" "a" "b" "a") user=> (take 10 (cycle (range 0 3))) (0 1 2 0 1 2 0 1 2 0)
Takes a body of expressions that returns an ISeq or nil, and yields
(defn cycle "Returns a lazy (infinite!) sequence of repetitions of the items in coll." {:added "1.0" :static true} [coll] (lazy-seq (when-let [s (seq coll)] (concat s (cycle s)))))
Comments top
No comments for cycle. Log in to add a comment.