function | since v0.0-927 | clojure.core/count | Edit |
(count coll)
Returns the number of items in coll
.
count
works on arrays, lists, maps, sets, strings, and vectors.
(count nil)
returns 0.
(count [1 2 3])
;;=> 3
(count [])
;;=> 0
(count nil)
;;=> 0
(count #{:a :b})
;;=> 2
(count {:key "value" :key2 "value2"})
;;=> 2
Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Maps
(defn count
[coll]
(if-not (nil? coll)
(cond
(implements? ICounted coll)
(-count coll)
(array? coll)
(alength coll)
(string? coll)
^number (.-length coll)
(implements? ISeqable coll)
(accumulating-seq-count coll)
:else (-count coll))
0))