Happy New to all of you!!!
Recently I came across the barber problem (again) and while reading it I
thought that code.async would be ideal for this kind of problem. Below is
the code I have come up with. I think it does the trick but I am not
entirely happy with it, for instance the fact that I
;(async/timeout (* 10 1000)) ;; not sure why this doesn’t work here, would
make it portable to clojureScript I think
Did you forget to use wrote:
> Happy New to all of you!!!
>
> Recently I came across the barber problem (again) and while reading it I
> thought that code.async would be ideal fo
On Friday, 2 January 2015 16:45:14 UTC, Erik Price wrote:
>
> ;(async/timeout (* 10 1000)) ;; not sure why this doesn’t work here,
> would make it portable to clojureScript I think
>
> Did you forget to use
> e
>
.. :) thank you!!!
Thomas
--
You received this message b
Looks like the barber's loop doesn't check the "running" atom, so it will
never stop...
If you wanted to get rid of the atom for counting haircuts you could use a
go-loop with a haircut count as an argument. Something like:
(go-loop [haircuts 0]
(if @running
(do (cut-hair!)
(recur
Your code is simple and easy to understand but it would look to see if
atoms can be removed. Also the use go/while loop makes your code not stop
and hence atom like @running is required.
This is my attempt to solve the problem. I started with your code as the
base and refactored it.
Following are
Thank you all for you valuable feedback. I really appreciate it and the
suggestions are really good.
Thomas
--
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 member
I'd suggest taking a look at the alts! function in core.async (or the
equivalent alt! macro).
On Monday, 5 January 2015, Thomas wrote:
> Thank you all for you valuable feedback. I really appreciate it and the
> suggestions are really good.
>
> Thomas
>
> --
> You received this message because yo