count

clojure.core

  • (count coll)
Returns the number of items in the collection. (count nil) returns
0. Also works on strings, arrays, and Java Collections and Maps

1 Example top

  • user=> (count nil)
    0
    
    user=> (count [])
    0
    
    user=> (count [1 2 3])
    3
    
    user=> (count {:one 1 :two 2})
    2
    
    user=> (count [1 \a "string" [1 2] {:foo :bar}])
    5
    
    user=> (count "string")
    6
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:809 top

(defn count
  "Returns the number of items in the collection. (count nil) returns
  0.  Also works on strings, arrays, and Java Collections and Maps"
  {
   :inline (fn  [x] `(. clojure.lang.RT (count ~x)))
   :added "1.0"}
  [coll] (clojure.lang.RT/count coll))
Vars in clojure.core/count:
Used in 0 other vars

Comments top

No comments for count. Log in to add a comment.