We needed this functionality too and ended up writing our own utility macro:
(defmacro condp->
"Takes an expression and a set of predicate/form pairs. Threads expr (via ->)
through each form for which the corresponding predicate is true of expr.
Note that, unlike cond branching, condp-> threading does not short circuit
after the first true test expression."
[expr & clauses]
(assert (even? (count clauses)))
(let [g (gensym)
pstep (fn [[pred step]] `(if (~pred ~g) (-> ~g ~step) ~g))]
`(let [~g ~expr
~@(interleave (repeat g) (map pstep (partition 2 clauses)))]
~g)))
So (condp-> {:x 1} #(= (:x %) 1) (assoc :x 2)) produces {:x 2} as desired.
We have a condp->> version as well.
Sean Corfield -- (904) 302-SEAN
An Architect's View --
http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood