Very likely Juan, as seen here:

(let [agents (map agent (range 30 35))]
  (doseq [a agents]
    (send a + 100)
    (println @a))
  (doseq [a agents]
    (println @a)))

For me that prints:

30
31
32
33
34
130
131
132
133
134

but I suspect that's more luck that anything since there's no reason
the agent operations need to have finished before the second println.

Kuba, as a separate issue, why are you trying to intern all those
symbols? It's not very idiomatic.

Sean


On Tue, Aug 20, 2013 at 4:49 PM, juan.facorro <juan.faco...@gmail.com> wrote:
> If on the println you don't see the value updated, it's probably because the
> operation sent to the agent wasn't applied yet.
>
> Add a (Thread/sleep 500) in between the send and println expressions and
> you'll see the expected agents'.
>
> Cheers,
>
> JF
>
>
> On Wednesday, August 21, 2013 12:21:59 AM UTC+1, Kuba Roth wrote:
>>
>> Hi there,
>> I've got a range of values and I'd like to run agents for each value per
>> thread. For some reason I've got only one agents being updated.
>> Not sure what's wrong here but I suspect  must be doing something terrible
>> stupid...
>>
>> Thanks!
>>
>> (doseq [s (range 30 35)]
>>        ;(println (format "_%s" s))
>>        (intern *ns* (symbol (format "_%s" s) ) (agent s))         ;; set
>> initial value
>>        (send @(intern *ns* (symbol (format "_%s" s))) + 100)      ;; send
>> agent and update value
>>        (println @(intern *ns* (symbol (format "_%s" s)) ))        ;; deref
>>  )
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to