Another solution, repeats itself slightly less: (assoc obj :key (or (:key obj) (something-else-with-side-effects-maybe?)))
Not sure I like it much better than the first one. But I usually prefer not writing my own macros/functions when I can avoid it, so it has that plus. On Sat, May 25, 2013 at 8:50 AM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > I just realised you can also do this to get the same effect of > pred-transform...This is the first time I'm using cond->! I'm starting to > realise its usefuleness... :) > > (let [rpred (complement pred)] > (cond-> obj > (pred obj) identity ;;if true return it untouched > (rpred obj) tf)) ;;if false do the transformation > > Jim > > > On 25/05/13 14:29, atkaaz wrote: > > yep that was interesting thanks btw; it was a function that was acting > like a macro, how odd > > > On Sat, May 25, 2013 at 4:26 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > >> so maybe a let + gensym would be in order? >>> >> >> >> yes that is what you do to avoid double-evaluation...:) I was making a >> different point though, the fact that definline produces a first class fn >> which still expands like a macro. >> >> Jim >> >> >> >> -- >> -- >> 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. > > > > > -- > -- > 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 a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojure/1GFesvqspwk/unsubscribe?hl=en. > To unsubscribe from this group and all its topics, 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.