Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created December 20, 2011 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/1499686 to your computer and use it in GitHub Desktop.
Save swannodette/1499686 to your computer and use it in GitHub Desktop.
example.clj
(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