• (conj coll x)
  • (conj coll x & xs)
conj[oin]. Returns a new collection with the xs
'added'. (conj nil item) returns (item). The 'addition' may
happen at different 'places' depending on the concrete type.

1 Example top

  • user=> (conj [1 2 3] 4)
    [1 2 3 4]
    
    user=> (conj '(1 2 3) 4)
    (4 1 2 3)
    
    user=> (conj ["a" "b" "c"] "d")
    ["a" "b" "c" "d"]
    
    user=> (conj [1 2] 3 4)               
    [1 2 3 4]
    
    user=> (conj [[1 2] [3 4]] [5 6])       
    [[1 2] [3 4] [5 6]]
    
    ;; Maps only take vectors of length exactly 2
    user=> (conj {1 2, 3 4} [5 6])
    {5 6, 1 2, 3 4}
    
Log in to add / edit an example.

See Also top

  • 1
    clojure.core/cons

    Returns a new seq where x is the first element and seq is the res

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:75 top

(def
 ^{:arglists '([coll x] [coll x & xs])
   :doc "conj[oin]. Returns a new collection with the xs
    'added'. (conj nil item) returns (item).  The 'addition' may
    happen at different 'places' depending on the concrete type."
   :added "1.0"
   :static true}
 conj (fn ^:static conj 
        ([coll x] (. clojure.lang.RT (conj coll x)))
        ([coll x & xs]
         (if xs
           (recur (conj coll x) (first xs) (next xs))
           (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.