Re: send agent inside doseq

2013-08-21 Thread Kuba Roth
Yup, I've done OOP in the past but probably even closer procedural programming. Recently I've been working pretty much exclusively in python/C++ which are somewhat at two extremes. I'm hoping to see Clojure to be a blend of these two and a replacement especially in areas where things in python are

send agent inside doseq

2013-08-20 Thread Kuba Roth
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

Re: send agent inside doseq

2013-08-20 Thread juan.facorro
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

Re: send agent inside doseq

2013-08-20 Thread Sean Corfield
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

Re: send agent inside doseq

2013-08-20 Thread Kuba Roth
Thanks Sean, your example looks much cleaner and most important works! The reason I looked into 'intern' can only be explained by totally lack of experience in Clojure and more general functional programming. My goal was to dynamically create a var inside the 'doseq' and apparently 'intern' is

Re: send agent inside doseq

2013-08-20 Thread Sean Corfield
On Tue, Aug 20, 2013 at 9:31 PM, Kuba Roth kuba.r...@gmail.com wrote: The reason I looked into 'intern' can only be explained by totally lack of experience in Clojure and more general functional programming. Ah, is your background OOP? You'll find the functional world is pretty different. No