Here's my solution to your problem. Let me know if it helps. ``` user> (defn if-attr [-key obj missing] (if-let [ret (get obj -key)] ret (assoc obj -key missing))) #'user/if-attr user> (if-attr :abc {} "missing-value") {:abc "missing-value"} user> (if-attr :abc {:abc 123} "missing-value") 123 user> ```
25.05.2013, 22:29, "atkaaz" <atk...@gmail.com>: > 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 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.