There's a reason why (seq coll) is a standard Clojure idiom, which the source for empty? reveals:
(defn empty?
"Returns true if coll has no items - same as (not (seq coll)).
Please use the idiom (seq x) rather than (not (empty? x))"
{:added "1.0"
:static true}
[coll] (not (seq coll)))
By using (not (empty? coll)), you are effectively writing (not (not (seq coll))), which isn't really very elegant, even if of marginal significance performance-wise.Curiously, he later champions the use of (some? x) rather than the arguably more readable (not (nil? x)), even though in this case the former is directly equivalent to the latter:
(defn some?
"Returns true if x is not nil, false otherwise."
{:tag Boolean
:added "1.6"
:static true}
[x] (not (nil? x)))
> correct, error-proof way to choose "first non-nil value" (cond
(some? a) a
(some? b) b
(some? c) c)
I'm sorry, but that's horrible. What if you had 20 items to check? Or an indeterminate number?How about:
(first (remove nil? [a b c]))