Hi All,

This post is just to mention my recent experience with one of the 
clojure.core/zipmap, by witch I was burned badly recently. Consider the 
following example code

(def ks [:a :b :c :d :e :f :b :c :d])

(def m (zipmap ks (range)))

(get m :b)

> 6

Of course the "ks" in my case was like 100-and-something names, which I 
didn't notice got concatenated twice by accident. Alright I accept, it was 
a ridiculously stupid mistake, but finding out what went wrong was 
definitely not straightforward (kind of questioning your sanity feeling)... 
I had to grab a friend for some "second pair of eyes" and her immediate 
reaction was "(= (count (distinct ks)) (count ks))", and said there you go.

Not sure if there is anything which could be improved on the docstring, or 
the behavior. Maybe if the docstring has put a tiny bit more emphasis on 
the implementation details: that it's going to be a reduce over the 
key-value pairs into an empty map, that would have triggered the "aha" 
moment for me.

Anyways, I am not claiming there is something to be improved / changed 
here, especially without affecting performance. This is just "for the 
record" / "future reference".

Cheers,

D.

-- 
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/d/optout.

Reply via email to