I have got in a shape where it works fine, but with slightly unusual 
behavior. I am looking for  advice on refactoring, So if someone could 
please have a look. 

https://gist.github.com/gamma235/4ea0d7a0d0efb8d4399f

Jesse




On Thursday, May 22, 2014 8:25:39 PM UTC+9, Rob Day wrote:
>
> I haven't taken a detailed look yet, but you say you're watching the 
> atom in a background loop - would 
> http://clojuredocs.org/clojure_core/1.2.0/clojure.core/add-watch be 
> more idiomatic and more efficient? 
>
> Best, 
> Rob 
>
> On 22 May 2014 14:17, Jesse <jesus.d...@gmail.com <javascript:>> wrote: 
> > Hey guys, I am trying to build a program that can instruct a single 
> > elevator, 2 floor system how to behave based on the state of an atom 
> that is 
> > being constantly checked for updates by a loop. The state of the atom at 
> a 
> > given time is then used to determine the conditional behavior of a 
> > move-elevator function. 
> > 
> > It is the first time I have ever written a program like this before, so 
> I am 
> > not sure if I am doing it efficiently or not. Everything works fine up 
> until 
> > the final init loop, where it freezes up my computer or ends 
> prematurely. In 
> > Joy of Clojure, I saw a cool program using case and trampoline that is 
> > related to elevators, but somewhat different from what I am doing. I am 
> not 
> > sure if those functions, cond, or perhaps condp, using recur, would be 
> > better for my use-case. 
> > 
> > I run a go-loop in the background that reads inputs from first or second 
> > floor button presses, up or down, from a channel, and updates the state 
> of 
> > an atom, that is read by the move-elevator function. I am not sure 
> if/how to 
> > call the move-elevator function to have the whole process run 
> continuously, 
> > by itself, after I call the init function. Right now I have to call the 
> > move-function manually. Other than that, the whole things works fine. 
> Could 
> > somebody please give me some helpful pointers to make my code more 
> > professional and/or sophisticated, or more general advice on using 
> Clojure 
> > to design programs that interface with in mechanical systems? Is using 
> an 
> > async channel to store presses here a good choice? This article here, 
> > creating ATM machine functionality using case and core.async, also 
> inspired 
> > me: 
> > 
> http://www.neo.com/2014/05/18/using-a-core-async-routine-as-a-state-machine 
> > 
> > The code is a little long (80 lines), so below is a link to the github 
> gist. 
> > 
> > https://gist.github.com/gamma235/4ea0d7a0d0efb8d4399f 
> > 
> > Thanks ahead of time! 
> > 
> > Jesse 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com<javascript:> 
> > Note that posts from new members are moderated - please be patient with 
> your 
> > first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com <javascript:> 
> > 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+u...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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/d/optout.

Reply via email to