You're viewing version 1.2.0 of empty. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

empty

clojure.core

  • (empty coll)
Returns an empty collection of the same category as coll, or nil

2 Examples top

  • user=> (empty [1 2 3])
    []
    
    user=> (empty (list 1 2 3))
    ()
    
    user=> (map empty [[\a \b] {1 2} (range 4)])
    ([] {} ())
    
    user=> (swap! (atom (range 10)) empty)      
    ()
  • ;; The output will not necessarily be of the same JVM class as the input
    user=> (class (seq [1]))
    clojure.lang.PersistentVector$ChunkedSeq
    
    user=> (class (empty (seq [1])))
    clojure.lang.PersistentList$EmptyList
    
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:4101 top

(defn empty
  "Returns an empty collection of the same category as coll, or nil"
  {:added "1.0"}
  [coll]
  (when (instance? clojure.lang.IPersistentCollection coll)
    (.empty ^clojure.lang.IPersistentCollection coll)))
Vars in clojure.core/empty: defn instance? when
Used in 3 other vars map-values -empty empty

Comments top

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