list*

clojure.core

  • (list* args)
  • (list* a args)
  • (list* a b args)
  • (list* a b c args)
  • (list* a b c d & more)
Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence.

1 Example top

  • ;; `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)
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:583 top

(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"
   :static true}
  ([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)))))))
Vars in clojure.core/list*:
Used in 0 other vars

Comments top

No comments for list*. Log in to add a comment.