Hi, Am 30.05.2009 um 02:37 schrieb Brian Carper:
Can anyone explain this? user> (def x {:foo :bar :foo :baz :foo :quux}) #'user/x user> x {:foo :bar, :foo :baz, :foo :quux} user> (count (keys x)) 3 user> (map x (keys x)) (:bar :bar :bar)
If I remember correctly, map literals smaller than a certain size are based on array-map. For speed reasons, this does not check for duplicate keys. If you increase the size of your literal beyond the threshold (was it something around twenty entries?) the map will be a hash-map and the effect should go away... My understanding is, that this falls under "do broken stuff and you'll get broken stuff". Map literals are most-likely small maps with hard-wired keys. So the chance to have a map like above is very small. And if there is one I would strongly question the correctness. So this shouldn't be a real problem in practice. Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature