clojureclojureclr

Clojure: finding out if a collection is seq-able


So there's list?, seq?, vector?, map? and so on to determine what type of collection the argument is.

What's a good way of telling the difference between

Is there a better way than

#(or (seq? %) (list? %) etc)

Solution

  • using seq? is about as concise and clean as it gets.

    clojure.contrib.core defines:

    seqable?
        function
        Usage: (seqable? x)
        Returns true if (seq x) will succeed, false otherwise.
    

    http://clojure.github.com/clojure-contrib/core-api.html

    it does what you proposed with one big or statement of