empty?

added
1.0

ns
clojure.core

type
function

(empty? coll)

Returns true if coll has no items - same as (not (seq coll)).
Please use the idiom (seq x) rather than (not (empty? x))

                user=> (empty? ())
true
user=> (empty? '(1))
false
            
                user=> (every? empty? ["" [] () '() {} #{} nil])
true

;example of recommended idiom for testing if not empty
user=> (every? seq ["1" [1] '(1) {:1 1} #{1}])
true
            
                user=> (drop-while empty? ["" [] "foobar"])
("foobar")
            
                user=> (empty? nil)
true
            
                ;; A collection with nothing in it is not empty.
(= true
   (every? false? [(empty? [nil])
                   (empty? #{nil})
                   (empty? '(nil))]))

;; But a collection of nothing is empty.
(= true
   (every? true? [(empty? [])
                  (empty? #{})
                  (empty? '())]))