I cheated and used 'every?' :) (defn andf [& preds] (fn [& args] (every? #(apply % args) preds)))
".Bill Smith" <william.m.sm...@gmail.com> writes: > I want to filter a list based on the logical AND of a set of > predicates. For example, let's say I have single-argument functions > f, g, and h (without side-effects), and I want those items x in the > list such that (f x), (g x) and (h x) are all true. I know I can do > this: > > (filter #(and (f %) (g %) (h %)) my-list) > > Is there a more terse way to express the same thing? I suspect there > is a mechanism similar to (or perhaps a generalization of) composition > for that, but I couldn't find it in the API docs. > > Bill Smith > Austin, TX -- Mark Triggs <mark.h.tri...@gmail.com> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en