title: How to test in Clojure if any given value is not-empty collection?
body: <p>I need a predicate which returns logically true if the given value is a not-empty collection and logically false if it's anything else (number, string etc.).
  And more specifically, that the predicate won't throw the <code>IllegalArgumentException</code> if applied to single number, or string.</p>
  
  <p>I came up with the following function, but I'm wondering if <strong>there is some more idiomatic approach?</strong></p>
  
  <pre class="lang-clj prettyprint-override"><code>(defn not-empty-coll? [x]
    (and (coll? x) (seq x)))
  </code></pre>
  
  <p>This will satisfy following tests:</p>
  
  <pre class="lang-clj prettyprint-override"><code>(is (not (not-empty-coll? nil)))    ;; -&gt; false
  (is (not (not-empty-coll? 1)))      ;; -&gt; false
  (is (not (not-empty-coll? "foo")))  ;; -&gt; false
  (is (not (not-empty-coll? [])))     ;; -&gt; nil      (false)
  (is (not (not-empty-coll? '())))    ;; -&gt; nil      (false)
  (is (not (not-empty-coll? {})))     ;; -&gt; nil      (false)
  (is (not-empty-coll? [1]))          ;; -&gt; (1)      (true)
  (is (not-empty-coll? '(1)))         ;; -&gt; (1)      (true)
  (is (not-empty-coll? {:a 1}))       ;; -&gt; ([:a 1]) (true)
  </code></pre>
  
  <p>EDIT: A potential use case:</p>
  
  <p>Let's say we need to process some raw external data which are not (yet) under our control. Input could be for example a collection which contains either primitive values, or nested collections. Other example could be a collection holding some inconsistent (maybe broken?) tree structure. So, we can consider mentioned predicate as first line data cleaning.</p>
  
  <p>Otherwise, I agree with comments that is better to explicitly separate and process collection and non-collection data.</p>