Welcome! Please see the About page for a little more info on how this works.

+1 vote
ago in Docs by

It seems the docstring on empty? is outdated, recommending to use seq to check for emptiness, even though nowodays empty? may be much faster (on counted collections):

(defn empty?
  "Returns true if coll has no items. To check the emptiness of a seq,
  please use the idiom (seq x) rather than (not (empty? x))"
  {:added "1.0"
   :static true}
  [coll]
  (if (counted? coll)
    (zero? (count coll))
    (not (seq coll))))

1 Answer

+1 vote
ago by

The docstring says "To check the emptiness of a seq..." which is still the preferred idiom.

ago by
Ah, thank you, I haven't read the docstring carefully enough. I read it as "a sequential collection" while it literally means "an implementation of `ISeq`"
...