Re: assoc! order problem

2012-08-05 Thread llj098
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

Re: assoc! order problem

2012-08-05 Thread Bronsa
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 liulijin.w...@gmail.com ha scritto: thanks for reply, I know the sorted-map, but my

Re: assoc! order problem

2012-08-05 Thread Evan Mezeske
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

Re: assoc! order problem

2012-08-05 Thread Christian Sperandio
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 emeze...@gmail.com a écrit : I know the sorted-map, but my question is : why the map is not 'ordered' when

assoc! order problem

2012-08-04 Thread llj098
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=

assoc! order problem

2012-08-04 Thread 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 because you are subscribed to the Google Groups Clojure group. To post to this

Re: assoc! order problem

2012-08-04 Thread Bronsa
Note that you can't use a sorted-map in a transient 2012/8/4 Jeff Heon jfh...@gmail.com 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

Re: assoc! order problem

2012-08-04 Thread Warren Lynn
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