This renames keys to avoid collisions, using an array map to preserve
the order of the keys:

user=> (rename-keys {1 :a 2 :b 3 :c}  (array-map 3 4 2 3 1 2))
{2 :a, 3 :b, 4 :c}

On May 11, 7:22 am, Armando Blancas <armando_blan...@yahoo.com> wrote:
> > (clojure.set/rename-keys {1 :a 2 :b 3 :c}  {1 2 2 3 3 4})
>
> > returns
>
> > {4 :a}
>
> That's caused by the collision between new and existing keys. Renaming
> 1 to 2 blows [2 :b]: {2 :a, 3 :c}; then renaming 2 to 3 blows [3 :c],
> leaving {3 :a}; and the last just renames 3 to 4: {4 :a}.

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