(->> people (filter :admin?) (filter :mod?))
This is admittedly a matter of taste, though.For the some-fn example, I would argue that the usage in OP is a very idealized and tuned example... how often do you really want to say "try this one predicate and if that doesn't work, try this other one"? I only need to do that maybe a couple of times a year (when parsing some sort of irregular raw data) so it's rare enough that I'd prefer to write the predicate explicitly instead of using this sort of succinct predicate composition that could become a "head-scratcher" at a future date.
(filter (every-pred :admin? :mod?) people)
is that a) this arguably conses less, by building only one results list, and b) :admin? and :mod? are just regular arguments, which means they could be replaced by data. I'm thinking of: (let [acl [:admin? :mod?]]
(filter (apply every-pred acl) people))
This capitalizes on Clojure's interesting design decision in which when funcalled, a :keyword resolves to function that gets an element with the name :keyword from the map passed as the argument.Aren't lazy sequences idiomatic in Clojure?
(filter (and| :admin? :mod?)
people)
and: (filter (or| :admin? :mod?)
people) (into []
(comp (filter :admin?)
(filter :mod?))
people)
As a side-effect, they are also more generic so you can reuse the transducer stack if you decide to use core.async or something.I’d also be a bit careful about judging popularity from open source codebases too: they are used heavily in all the production code based I maintain :) and I get the sense that they’re pretty widely used by the “silent majority” of clojure programmers.
My debugging strategy for them is basically what I do for threading macros anyways: (into [] (comp ... (map #(doto % (->> (println :it))) ....) inp)