I wrote pred-cond for Midje way back, which does what you want. https://github.com/marick/Midje/blob/master/src/midje/clojure/core.clj#L176
Example use: https://github.com/marick/Midje/blob/master/src/midje/parsing/1_to_explicit_form/facts.clj#L100 Like normal cond pred-cond will short-circuit once it hits a match (so unlike con->) On Tue, Feb 11, 2014 at 11:36 PM, <s...@corfield.org> wrote: > I use cond-> quite a lot but I find myself often wanting a version that > uses predicate functions rather than expressions which would seem > more “threaded”. Am I just missing a better way to write these things? > > For example: > > (cond-> accounts > (empty? accounts) (conj “stuff”)) > > That just screams for something like: > > (condp-> accounts > empty? (conj “stuff”)) > > Then you could thread the predicates: > > (condp-> a > p1 (f1 args) > p2 (f2 args)) > > which would be: > > (let [x (if (p1 a) (f1 a args) a)] > (if (p2 x) (f2 x args) x)) > > Suggestions? > > Sean Corfield -- (904) 302-SEAN > An Architect's View -- http://corfield.org > World Singles, LLC - http://worldsingles.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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.