user=> (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6
6 7 7 8 8 9 9})
{3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 1 2}
user=> (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6
6 7 7 8 8})
{1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8}
Granted, it's not casual Clojure code but it's surprising.
Christophe
--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (en)
Fixing array-map would make the two tests consistent but I'm not sure
that (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 }) should
evaluate to {1 2}.
> What governs which class {} will return? The number of arguments?
Yes. The current implementation of Clojure's literal map reader
returns a PersistentArrayMap if there are 8 entries or fewer and a
PersistentHashMap otherwise.
--Steve