On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates <colin.ya...@gmail.com> wrote: > way to take the wind out of our sails! Well spotted :).
It's not too hard to fix. Here's an adapted version of Jonas' solution that should do the trick: (defn uniqueify [items] (first (reduce (fn [[results count-map] item] (let [n (count-map item 0)] (if (zero? n) [(conj results item) (assoc count-map item (inc n))] (recur [results (assoc count-map item (inc n))] (str item \_ n))))) [[] {}] items))) => (uniqueify ["a" "a" "a" "a" "b" "a_2" "a_3" "a_3_1" "a_3_1" "a"]) ["a" "a_1" "a_2" "a_3" "b" "a_2_1" "a_3_1" "a_3_1_1" "a_3_1_2" "a_4"] -- -- 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.