On Sun, Dec 14, 2008 at 5:48 AM, bOR_ <boris.sch...@gmail.com> wrote:
>
> Can anyone tell me what mistake I am making?
>
> (time
>  (do
>   (dotimes i popsize
>            (send-off (agent i)
>                      (doseq a [birth death infect infect evolve
> evolve evolve evolve evolve] (a i))))
>   (println "We've send off the whole population")
>   (dosync (commute year inc))))

'send-off' takes a function, not a block of code, so your 'doseq' does
all its work in the main thread.  Since 'doseq' always returns nil,
that's the action you're sending to each agent. If you were
maintaining a reference to each agent, you'd be able to dereference
any of them and see it has errors:

user=> (def x (agent nil))
#'user/x
user=> @x
nil
user=> (send-off x nil)
#<Agent clojure.lang.ag...@578073>
user=> @x
java.lang.Exception: Agent has errors (NO_SOURCE_FILE:0)

--Chouser

--~--~---------~--~----~------------~-------~--~----~
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
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