Created
December 20, 2011 00:55
-
-
Save swannodette/1499686 to your computer and use it in GitHub Desktop.
example.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn make-cursor [x y] | |
{:x x :y y}) | |
(defn left [cursor] | |
(update-in cursor [:x] #(- % 20)) | |
(defn right [cursor] | |
(update-in cursor [:x] #(+ % 20)) | |
(defn draw-cursor [g s {:keys [x y]}] (.drawString g s x y)) | |
;; ===== | |
;; usage | |
(def my-cursor (atom (make-cursor 0 0))) | |
(swap! my-cursor right) | |
(swap! my-cursor right) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment