>   user> (loop [thm (transient {}),
>                i 0]
>           (if (<= 10 i)
>             (persistent! thm)
>             (recur (assoc! thm i i)
>                    (inc i))))
>   {0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9}
>

By the way, FYI:

(reduce #(assoc %1 %2 %2) {} (range 10))

or

(persistent! (reduce #(assoc! %1 %2 %2) (transient {}) (range 10)))

Reduce is handy for repeatedly assoc'ing into a hash-map.

Justin

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