You're viewing version 1.2.0 of cycle. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

cycle

clojure.core

  • (cycle coll)
Returns a lazy (infinite!) sequence of repetitions of the items in coll.

1 Example top

  • 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)
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2211 top

(defn cycle
  "Returns a lazy (infinite!) sequence of repetitions of the items in coll."
  {:added "1.0"}
  [coll] (lazy-seq 
          (when-let [s (seq coll)] 
              (concat s (cycle s)))))
Vars in clojure.core/cycle: concat defn lazy-seq when-let
Used in 0 other vars

Comments top

No comments for cycle. Log in to add a comment.