1.3.0 permalink Arrow_down_16x16

conj!

clojure.core

  • (conj! coll x)
Alpha - subject to change.
Adds x to the transient collection, and return coll. The 'addition'
may happen at different 'places' depending on the concrete type.

1 Example top

  • ;; As seen on http://clojure.org/transients
    ;; array is initially made transient, modified then
    ;; finally made persistent.
    
    ;; Note: This example correctly always uses the return value of conj! for
    ;; future modifications, not the original value of v.  See assoc! examples
    ;; for some discussion of why this is important.
    
    (defn vrange2 [n]
      (loop [i 0 v (transient [])]
        (if (< i n)
          (recur (inc i) (conj! v i))
          (persistent! v))))
    
    user=> (vrange2 10)
    [0 1 2 3 4 5 6 7 8 9]
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:2941 top

(defn conj!
  "Alpha - subject to change.
  Adds x to the transient collection, and return coll. The 'addition'
  may happen at different 'places' depending on the concrete type."
  {:added "1.1"
   :static true}
  [^clojure.lang.ITransientCollection coll x]
  (.conj coll x))
Vars in clojure.core/conj!:
Used in 0 other vars

Comments top

No comments for conj!. Log in to add a comment.