Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence.
;; `list*` function: user=> (list* 1 [2 3]) (1 2 3) user=> (list* 1 2 [3 4]) (1 2 3 4) ;; compared to regular `list` function: user=> (list 1 [2 3]) (1 [2 3]) user=> (list 1 2 [3 4]) (1 2 [3 4]) ;; Corner cases: user=> (list* nil [1 2]) (nil 1 2) user=> (list* 1 nil) (1) user=> (list* () [1 2]) (() 1 2) user=> (list* 1 ()) (1)
(defn list*
"Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence."
{:added "1.0"}
([args] (seq args))
([a args] (cons a args))
([a b args] (cons a (cons b args)))
([a b c args] (cons a (cons b (cons c args))))
([a b c d & more]
(cons a (cons b (cons c (cons d (spread more)))))))
Comments top
No comments for list*. Log in to add a comment.