I cheated and used 'every?' :)
(defn andf [& preds]
(fn [& args]
(every? #(apply % args) preds)))
".Bill Smith" <[email protected]> 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
<[email protected]>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en