On Jan 6, 2011, at 1:48 PM, Ken Wesson wrote:
> On Thu, Jan 6, 2011 at 1:08 PM, Raoul Duke wrote:
>> On Thu, Jan 6, 2011 at 3:32 AM, Baishampayan Ghose wrote:
>>> Haha! Same here. I have used transients many times too, but I fell
>>> into the trap this time :)
>>
>> now if only there were some
On Thu, Jan 6, 2011 at 1:08 PM, Raoul Duke wrote:
> On Thu, Jan 6, 2011 at 3:32 AM, Baishampayan Ghose wrote:
>> Haha! Same here. I have used transients many times too, but I fell
>> into the trap this time :)
>
> now if only there were some kind of programming language technology
> that could he
On Thu, Jan 6, 2011 at 3:32 AM, Baishampayan Ghose wrote:
> Haha! Same here. I have used transients many times too, but I fell
> into the trap this time :)
now if only there were some kind of programming language technology
that could help us figure out when we're mis-applying operations to
thing
http://clojure.org/transients
mentions that transients are not designed to be bashed in place like mutable
datastructures.
The following produces the correct result.
(loop [x (transient {}) i 0]
(if (< i 10)
(recur (assoc! x i (* i i)) (inc i))
(persistent! x)))
--
You receive
> thanks for the clarification .. I did know about the fact that I have to
> capture the return value .. but some how slipped my mind and assumed it was
> a bug .. I guess that will never happen again after burning my fingers this
> time
Haha! Same here. I have used transients many times too,
thanks for the clarification .. I did know about the fact that I have to
capture the return value .. but some how slipped my mind and assumed it was
a bug .. I guess that will never happen again after burning my fingers this
time
Sunil.
On Thu, Jan 6, 2011 at 4:30 PM, Joost wrote:
> Joost
Joost wrote:
> you're supposed to use assoc! and
> friends as if they're pure functions.
Just correcting myself for clarity:
assoc! etc MAY modify their transient arguments, but not always, and
not always in the way you might think. The correct result of these
operations is their return value, bu
Sunil S Nandihalli writes:
> Hello everybody,
> the following code is not producing what was expected of it in clojure
> 1.2 .. has this been fixed the clojure 1.3?
>
> (let [x (transient {})]
> (dotimes [i 10]
> (assoc! x i (* i i)))
> (persistent! x))
This is not a bug, it's a misuse o
That is not a bug. You should NEVER use transient and its related
functions to emulate variables - you're supposed to use assoc! and
friends as if they're pure functions. That is, always use the return
value of assoc! and don't rely on its argument being modified.
something like:
(loop [x (transi
Yea you are right it does not work for anything greater than 8 .. It took me
a while to figure out that the bug was infact the transients.. but did you
try it in clojure 1.3 alpha versions?
Sunil.
On Thu, Jan 6, 2011 at 3:35 PM, Baishampayan Ghose wrote:
> > Hello everybody,
> > the following co
> Hello everybody,
> the following code is not producing what was expected of it in clojure 1.2
> .. has this been fixed the clojure 1.3?
> (let [x (transient {})]
>
>
> (dotimes [i 10]
>
>
> (assoc! x i (* i i)))
>
>
>
11 matches
Mail list logo