Skip to content

Instantly share code, notes, and snippets.

@newsomc
Forked from swannodette/refactor.clj
Created November 12, 2013 12:56
Show Gist options
  • Save newsomc/7430349 to your computer and use it in GitHub Desktop.
Save newsomc/7430349 to your computer and use it in GitHub Desktop.
(defn computer-down? [{{computer-y :y} :computer
{ball-y :y} :ball player-height :player-height :as state}]
(and (> (- computer-y 20) ball-y) (>= (- computer-y (/ player-height 2)) 0)))
;; vs.
(defn computer-down? [{:keys [ball computer] :as st}]
(let [cy (:y computer)]
(and (> (- cy 20) (:y ball))
(>= (- cy (/ (:player-height st) 2)) 0))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment