Skip to content

Instantly share code, notes, and snippets.

@melbourne2991
Created October 26, 2018 05:29
Show Gist options
  • Save melbourne2991/728403e8b831c6febc46c619958e26c9 to your computer and use it in GitHub Desktop.
Save melbourne2991/728403e8b831c6febc46c619958e26c9 to your computer and use it in GitHub Desktop.
Clojure stuff
(def grid (atom [
[0 0 0]
[0 0 0]
[0 0 0]
]))
(defn update-grid [row-index col-index val]
(swap! grid assoc-in [row-index col-index] val))
(defn full-row? [row]
(every? pos? row))
(defn winner? []
(or (
(some full-row? (get-cols))
(some full-row? @grid))))
(defn get-cols [] (vec (apply map vector @grid)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment