coll?

clojure.core

  • (coll? x)
Returns true if x implements IPersistentCollection

3 Examples top

  • user=> (coll? {})
    true
    
    user=> (coll? #{})
    true
    
    user=> (coll? [])
    true
    
    user=> (coll? ())
    true
    
    user=> (coll? 4)
    false
    
    user=> (coll? "fred")
    false
    
    user=> (coll? true)
    false
    
    user=> (coll? nil)
    false
    
  • user=> (coll? {:a 10 :b 20}) ; map is a collection of map-entries
    true
  • ;; contrast to example code for sequential?
    ;;
    user> (coll? '(1 2 3))
    true
    user> (coll? [1 2 3])
    true
    user> (coll? (range 1 5))
    true
    user> (coll? 1)
    false
    user> (coll? {:a 2 :b 1})   
    true
    user> (coll? {:a 2 :b 1})  ; in contrast to sequential?, coll? returns true for a hash map
    true
    user> (sequential? {:a 2 :b 1})
    false
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:5453 top

(defn coll?
  "Returns true if x implements IPersistentCollection"
  {:added "1.0"
   :static true}
  [x] (instance? clojure.lang.IPersistentCollection x))
Vars in clojure.core/coll?:
Used in 0 other vars

Comments top

No comments for coll?. Log in to add a comment.