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]
  (if (or (nil? coll)
          (implements? ISeq coll))
    (Cons. nil x coll nil)
    (Cons. nil x (seq coll) nil)))