The best way in clojure is to return seq, or nil if its empty

Is there a better way to implement this?

(if (empty? a-seq)
    nil
    a-seq)
+3
source share
2 answers

Use the seq function , it does just that.

+10
source

I don’t know how I missed this in the documents, but not-empty does exactly that (thanks Guillermo for re-reading the documents).

+6
source

All Articles