title: Keeping State in a Purely Functional Language
body: <p>I am trying to figure out how to do the following, assume that your are working on a controller for a DC motor you want to keep it spinning at a certain speed set by the user,</p>
  
  <pre>
  <code>
  (def set-point (ref {:sp 90}))
  
  (while true
    (let [curr (read-speed)]
      (controller @set-point curr)))
  
  </code>
  </pre>
  
  <p>Now that set-point can change any time via a web a application, I can't think of a way to do this without using ref, so my question is how functional languages deal with this sort of thing? (even though the example is in clojure I am interested in the general idea.)</p>