SHARE
TWEET

Untitled

a guest Nov 26th, 2012 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn make-wire []
  2.   (let [value (atom 0)]
  3.     {
  4.     :get (fn [] @value )
  5.     :set (fn [new-value] reset! value new-value)
  6.   }))
  7.  
  8. (def x (make-wire))
  9. ((:get x))
  10. ; 0
  11. ((:set x) 5)
  12. ; 5
  13. ((:get x))
  14. ;0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top