repeat

clojure.core

  • (repeat x)
  • (repeat n x)
Returns a lazy (infinite!, or length n if supplied) sequence of xs.

1 Example top

  • user=> (take 5 (repeat "x"))
    ("x" "x" "x" "x" "x")
    
    ;; which is the same as:
    user=> (repeat 5 "x")
    ("x" "x" "x" "x" "x")
    
    ;; It should be noted that repeat simply repeats the value n number of times.
    ;; If you wish to execute a function to calculate the value each time you 
    ;; probably want the repeatedly function.
    
    
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:2578 top

(defn repeat
  "Returns a lazy (infinite!, or length n if supplied) sequence of xs."
  {:added "1.0"
   :static true}
  ([x] (lazy-seq (cons x (repeat x))))
  ([n x] (take n (repeat x))))
Vars in clojure.core/repeat:
Used in 0 other vars

Comments top

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