Is there a Clojure predicate that means "collection but not map"?
Such a predicate is / will be valuable because there are many operations that can be performed for all collections except maps. For example, (apply + ...)or (reduce + ...)can be used with vectors, lists, lazy sequences and sets, but not with maps, because map elements in this context end with clojure.lang.MapEntrys. It installs and displays what causes the problem with those predicates that I know of:
sequential?true for vectors, lists, and lazy sequences, but false for both maps and sets. ( seq?similar, but not true for vectors.)coll?and seqable?are true for both sets and cards, as well as for any other kind of collection that I can think of.
Of course, I can define such a predicate, for example. eg:
(defn coll-but-not-map?
[xs]
(and (coll? xs)
(not (map? xs))))
or like this:
(defn sequential-or-set?
[xs]
(or (sequential? xs)
(set? xs)))
I am wondering if there is a built-in predicate clojure.core (or a library tab) that does the same thing.
This question is connected with this and this , but did not answer their answers. (If my question is a duplicate of one that I did not find, I am glad that it is marked as such.)
source
share