function/macro | since v0.0-927 | clojure.core/list | Edit |
(list & xs)
Creates a new list containing items
.
Creates a new list containing the items.
(defn list
[& xs]
(let [arr (if (and (instance? IndexedSeq xs) (zero? (.-i xs)))
(.-arr xs)
(let [arr (array)]
(loop [^not-native xs xs]
(if-not (nil? xs)
(do
(.push arr (-first xs))
(recur (-next xs)))
arr))))]
(loop [i (alength arr) r ()]
(if (> i 0)
(recur (dec i) (-conj r (aget arr (dec i))))
r))))
(core/defmacro list
([]
'(.-EMPTY cljs.core/List))
([x]
`(cljs.core/List. nil ~x nil 1 nil))
([x & xs]
(core/let [cnt (core/inc (count xs))]
`(cljs.core/List. nil ~x (list ~@xs) ~cnt nil))))