Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created July 3, 2011 20:31
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 amalloy/1062579 to your computer and use it in GitHub Desktop.
Save amalloy/1062579 to your computer and use it in GitHub Desktop.
(defn move-piece [board old-pos new-pos]
(let [moving-piece (get-in board old-pos)]
(reduce (fn [acc [ks v]] (assoc-in acc ks v)),
board, [[old-pos nil] [new-pos moving-piece]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment