Hi,
By default, maps are array-map for short map and hash map for larger one.
That explains why the map seems sorted at the beginning.
Christian
Le 5 août 2012 à 10:40, Evan Mezeske a écrit :
> I know the sorted-map, but my question is : why the map is not 'ordered' when
> size is larger tha
>
> I know the sorted-map, but my question is : *why the map is not 'ordered'
> when size is larger than 32 ?*
>
Because a hash-map is never guaranteed to be sorted. In your case, it
sounds like Clojure is being smart and using a different implementation for
small maps (say, less than 32 elem
because of performance reasons, hash-maps are not ordered.
the fact that they are ordered for the first 32 elements is just an
implementation detail you shouldn't rely on
Il giorno 05/ago/2012 10.10, "llj098" ha scritto:
> thanks for reply,
>
> I know the sorted-map, but my question is : *why the
thanks for reply,
I know the sorted-map, but my question is : *why the map is not 'ordered'
when size is larger than 32 ? *
*
*
*
*
On Sunday, August 5, 2012 3:53:04 AM UTC+8, Jeff Heon wrote:
>
> You are using the map literal, which corresponds to the hash map.
>
> Use this if you want a sorted
I have not used transient yet so I don't understand your code. But for
ordered maps, I use ArrayMap.
--
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
Note that you can't use a sorted-map in a transient
2012/8/4 Jeff Heon
> You are using the map literal, which corresponds to the hash map.
>
> Use this if you want a sorted map:
> http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/sorted-map
>
> --
> You received this message b
You are using the map literal, which corresponds to the hash map.
Use this if you want a sorted map:
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/sorted-map
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this grou
Hi list,
I'm learning Clojure now and I was confused by assoc!.
Here is my code , I want to use the code to distinct items (I cannot use
'distinct' function here for some reasons.)
(defn fn2[x]
(vals (persistent!
(reduce (fn [ret l] (assoc! ret l l ))
(transient {}) x
user=>