cons

functionsince v0.0-927 clojure.core/consEdit
(cons x coll)

Details:

Returns a new sequence where x is the first element and coll is the rest.


Examples:

(cons 1 (list 1 2 3))
;;=> (1 1 2 3)

(cons 1 [1 2 3])
;;=> (1 1 2 3)

(cons 1 nil)
;;=> (1)

(cons nil nil)
;;=> (nil)

See Also:


Source docstring:
Returns a new seq where x is the first element and coll is the rest.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn cons
  [x coll]
  (cond
    (nil? coll)             (List. nil x nil 1 nil)
    (implements? ISeq coll) (Cons. nil x coll nil)
    :default                (Cons. nil x (seq coll) nil)))