Skip to main content

list

macrov1.7

cljs.core/list

Available in:BBCLJCLJS
(list [& xs])
Creates a new list containing the items.
;; basic creation

(list)              ;=> ()

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

(list :a "b" 3)     ;=> (:a "b" 3)   ; heterogeneous values are fine


;; list vs literal '(...)

(list (+ 1 2) (+ 3 4))   ;=> (3 7)        ; args are evaluated

'((+ 1 2) (+ 3 4))       ;=> ((+ 1 2) (+ 3 4))   ; quoted, not evaluated 

Use list when you want the args computed, use a quoted literal when you want the forms themselves (e.g., to build code).

;; list vs vector — pick by access pattern

(list 1 2 3)     ;=> (1 2 3)   ; O(1) prepend, O(n) random access

(vector 1 2 3)   ;=> [1 2 3]   ; O(log32 n) random access, O(1) append

Reach for list when you'll mostly cons/conj to the front (recursive sequence builds, code generation), use vector when you need indexed access.

;; lists as code (homoiconicity)

(eval (list '+ 1 2 3))   ;=> 6

constructing a list whose first element is a symbol gives you an expression you can hand to eval, defmacro, etc.
CLJCLJSBBJacek Schae · Apr 26, 2026