clojure.core/list*¶
Creates a new seq containing the items prepended to the rest, the last of which will be treated as a sequence.
Examples¶
Note by miner¶
The doc string mentions returning a new list, but it should say a new sequence. Surprisingly, list* typically does not return an actual list. Instead, it usually returns a Cons, which works as a seq, but is not strictly a list.
(list? (list* 1 '(2 3)))
;=> false
(type (list* 1 '(2 3)))
;=> clojure.lang.Cons
(first (list* 1 '(2 3)))
;=> 1
(peek (list* 1 '(2 3)))
ClassCastException clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack
(list? (list* '(2 3)))
;=> true
(list? (into () (list* 1 '(2 3))))
;=> true
I think seq* would have been a better name for this function.
Content from the matching ClojureDocs page, with authors credited on each contribution.