Skip to content

Instantly share code, notes, and snippets.

@foogoof
Created May 24, 2010 15:25
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 foogoof/dff8b0becc9d2c8b1bc8 to your computer and use it in GitHub Desktop.
Save foogoof/dff8b0becc9d2c8b1bc8 to your computer and use it in GitHub Desktop.
(defn make-mover [method & attribs]
(fn [xy]
(reduce
(fn [memo attrib]
(update-in memo [attrib] method))
xy
attribs)))
(def movers {:horiz (make-mover inc :x)
:vert (make-mover inc :y)
:diag-r (make-mover inc :x :y)
:diag-l (make-mover dec :x :y)})
((movers :diag-r) {:x 0, :y 0}) ;; {:x 1, :y 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment