Created
December 3, 2011 19:52
-
-
Save tfnico/1427957 to your computer and use it in GitHub Desktop.
Started Clojure game-of-life
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns conways.test.core | |
(:use [conways.core]) | |
(:use [clojure.test])) | |
(def world #{}) | |
(defn isALive? [world x y] (get world [x y]) ) | |
(defn setLive [world x y] (conj world [x y])) | |
(defn willSurvive? [world x y] false) | |
(defn perm [world] (filter (fn [[x y]] (willSurvive? world x y) ) world)) | |
(deftest emptyWorld | |
(is (not (isALive? world 0 0))) | |
) | |
(deftest oneCellWorld | |
(is (isALive? (setLive world 0 0) 0 0)) | |
) | |
(deftest oneCellWorldDisapears | |
(is (not (isALive? (perm (setLive world 0 0)) 0 0))) | |
) | |
(deftest emptyWorld2 | |
(is (= 0 (count world))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, this one in particular left me craving for more :)