What is the correct “clojure way” to check if a collection is non empty

According to Joy of Clojure, nil punning with seq is idiomatic:

(defn print-seq [s]
  (when (seq s)
    (prn (first s))
    (recur (rest s))))

“…the use of seq as a terminating condition is the idiomatic way to test whether a sequence is empty. If we tested [in the above example] just s instead of (seq s), then the terminating condition wouldn’t occur even for empty collections…”

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)