Re: reduce-kv doesn't reduce a sorted-map in order
Sounds like a bug to me, in that it doesn't behave as I would expect. On Thu, Aug 9, 2012 at 7:29 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Hi, It seems reduce-kv doesn't reduce a sorted-map in the correct order. Example - user (def *sm (into (sorted-map) {:aa 1 :zz 2 :bb 3 :yy 4 :cc 5 :xx 6})) ;= #'user/*sm user *sm ;= {:aa 1, :bb 3, :cc 5, :xx 6, :yy 4, :zz 2} ;; plain reduce user (reduce (fn [ret e] (conj ret e)) [] *sm) ;= [[:aa 1] [:bb 3] [:cc 5] [:xx 6] [:yy 4] [:zz 2]] ; correct ;; reduce-kv user (reduce-kv (fn [ret k v] (conj ret [k v])) [] *sm) ;= [[:cc 5] [:bb 3] [:aa 1] [:yy 4] [:xx 6] [:zz 2]] ; incorrect Is this a bug? Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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 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
Re: reduce-kv doesn't reduce a sorted-map in order
Confirmed -- thanks for the report. Stu Hi, It seems reduce-kv doesn't reduce a sorted-map in the correct order. Example - user (def *sm (into (sorted-map) {:aa 1 :zz 2 :bb 3 :yy 4 :cc 5 :xx 6})) ;= #'user/*sm user *sm ;= {:aa 1, :bb 3, :cc 5, :xx 6, :yy 4, :zz 2} ;; plain reduce user (reduce (fn [ret e] (conj ret e)) [] *sm) ;= [[:aa 1] [:bb 3] [:cc 5] [:xx 6] [:yy 4] [:zz 2]] ; correct ;; reduce-kv user (reduce-kv (fn [ret k v] (conj ret [k v])) [] *sm) ;= [[:cc 5] [:bb 3] [:aa 1] [:yy 4] [:xx 6] [:zz 2]] ; incorrect Is this a bug? Regards, BG -- 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
reduce-kv doesn't reduce a sorted-map in order
Hi, It seems reduce-kv doesn't reduce a sorted-map in the correct order. Example - user (def *sm (into (sorted-map) {:aa 1 :zz 2 :bb 3 :yy 4 :cc 5 :xx 6})) ;= #'user/*sm user *sm ;= {:aa 1, :bb 3, :cc 5, :xx 6, :yy 4, :zz 2} ;; plain reduce user (reduce (fn [ret e] (conj ret e)) [] *sm) ;= [[:aa 1] [:bb 3] [:cc 5] [:xx 6] [:yy 4] [:zz 2]] ; correct ;; reduce-kv user (reduce-kv (fn [ret k v] (conj ret [k v])) [] *sm) ;= [[:cc 5] [:bb 3] [:aa 1] [:yy 4] [:xx 6] [:zz 2]] ; incorrect Is this a bug? Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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