Here's what I speculate the problem is:

Last time I checked, contains? doesn't work on transient sets.
Try rewriting (contains? tset %) as (tset %).

Let me know if that change fixes your program.  This is a bug I reported
something like 1-2 years ago.  If this turns out to be the source of your
problem, I'm disappointed to hear it is still not fixed in 1.3.

--Mark

On Fri, Sep 16, 2011 at 10:53 AM, Alan Malloy <a...@malloys.org> wrote:

> Certainly looks like a valid use of transients. Might be related to
> http://dev.clojure.org/jira/browse/CLJ-829 but I dunno.
>
> On Sep 16, 9:55 am, Sergey Didenko <sergey.dide...@gmail.com> wrote:
> > 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 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

Reply via email to