When I convert the following code to use transients it returns
different result. Am I doing anything wrong or is it a bug in
transients?
(defn tt []
(loop [i 0 tset #{}]
(if (= i (int 5e5))
(count tset)
(recur (inc i)
(let [nn (rem (* i (int 1e3)) 131071)
plus (count (filter #(contains? tset %) (range nn
(+ nn 10))))
]
(conj tset (+ plus nn)))))))
(tt)
131074
(defn tt []
(loop [i 0 tset (transient #{})]
(if (= i (int 5e5))
(count (persistent! tset))
(recur (inc i)
(let [nn (rem (* i (int 1e3)) 131071)
plus (count (filter #(contains? tset %) (range nn
(+ nn 10))))
]
(conj! tset (+ plus nn)))))))
(tt)
131071
P.S. Tested under 1.3-RC0 and 1.2.1
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en