On Nov 28, 5:36 pm, Takahiro Hozumi <fat...@googlemail.com> wrote:
> Which style do you like?

This one:

> (defn dec-or-dissoc! [key]
>   (dosync
>    (alter *counts*
>           (fn [m]
>             (let [n (m key)]
>               (if (< 1 n)
>                 (assoc m key (dec n))
>                 (dissoc m key)))))))

I like to avoid deref'ing inside alter, instead relying on the value
passed in to the altering function.

The other one looks more like imperative code.

-S

-- 
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

Reply via email to