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

replicate

clojure.core

  • (replicate n x)
Returns a lazy seq of n xs.

1 Example top

  • user=> (apply str (replicate 7 \space))
           ; 7 spaces
    
    user=> (replicate 7 (rand-int 10))
    (3 3 3 3 3 3 3) ; the same number
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:2236 top

(defn replicate
  "Returns a lazy seq of n xs."
  {:added "1.0"}
  [n x] (take n (repeat x)))
Vars in clojure.core/replicate: defn repeat take

Comments top

1 comment(s) for replicate.

Note that replicate is obsolete. It's functionality is now available via the two-arg arity form of repeat.

Log in to add a comment.