Skip to content

Instantly share code, notes, and snippets.

@sztamas
sztamas / gist:6385704
Last active Dec 22, 2015
Clojure generating squares with colors.
View gist:6385704
(def FILES "abcdefgh")
(def RANKS (range 1 9))
(def squares (for [f FILES r RANKS] {:file f :rank r :name (str f r)}))
(defn opposite-color [col] (if (= col :light) :dark :light))
(defn alternate-colors [start-with]
(lazy-seq (cons start-with (alternate-colors (opposite-color start-with)))))
(def file-first-square-color (take 8 (alternate-colors :dark)))