Ah. I guess the elves should be a bit more then just a number, and
perhaps be agents themselves, that come to santa with a {:toy :broken}
and leave with a {:toy :fixed}, if we want the santa problem to be bit
more applicable in reality. What is everyone assuming that the program
should do at minimum? I see people assuming that santa needs time to
fix whatever the 3 elves are bringing to him, for example.

On May 6, 10:32 am, bOR_ <boris.sch...@gmail.com> wrote:
> Why isn't this enough for the problem? Elves and deer are entering
> Santa's frontdoor 1 at a time, when there is three elves in the room,
> santa instantly deals with them (resetting the number of elves to 0),
> when there is 9 deer in the room, santa goes sleighing.
>
> (def santa (agent {:elves 0 :deer 0}))
>
> (defn add-deer [san]
>    (if (= (:deer san) 8) (prn "sleighing time!")
>        (assoc san :deer (inc (:deer san)))))
>
> (defn add-elf [san]
>    (if (= (:elves san) 2) (assoc san :elves 0)
>        (assoc san :elves (inc (:elves san)))))
>
> ; still needs a thread that spits out (send santa add-elf) at
> irregular intervals
> ; still needs a thread that spits out (send santa add-deer) at
> irregular intervals
> ; where it says "sleighing time", we need to shutdown the other
> threads, clear, or
> ; ignore whatever sends to santa are still queued up, and printout a
> message
> ; saying that it is christmas time.
>
> ; but I don't know yet how to do those things, and it is time to head
> for work ;).
--~--~---------~--~----~------------~-------~--~----~
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