cljs.spec.alpha/cat
(cat & key-pred-forms)
Source docstring:
Takes key+pred pairs, e.g.
(s/cat :e even? :o odd?)
Returns a regex op that matches (all) values in sequence, returning a map
containing the keys of each pred and the corresponding value.
(defmacro cat
[& key-pred-forms]
(let [pairs (partition 2 key-pred-forms)
keys (mapv first pairs)
pred-forms (mapv second pairs)
pf (mapv #(res &env %) pred-forms)]
(clojure.core/assert (clojure.core/and (even? (count key-pred-forms)) (every? keyword? keys)) "cat expects k1 p1 k2 p2..., where ks are keywords")
`(cat-impl ~keys ~pred-forms '~pf)))