This file contains 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
(def NIL (symbol "NIL")) | |
(deftype ConsCell [CAR CDR] | |
clojure.lang.ISeq | |
(cons [this x] (ConsCell. x this)) | |
(first [this] (.CAR this)) | |
;; next and more must return ISeq: | |
;; https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java | |
(more [this] (if | |
(= (.CDR this) NIL) |
This file contains 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 game-of-life.core) | |
(def world [[2 1] [2 2] [1 1]]) | |
(defn neighbours [[x y]] | |
[[(dec x) (dec y)] [x (dec y)] [(inc x) (dec y)] | |
[(dec x) y] [(inc x) y] | |
[(dec x) (inc y)] [x (inc y)] [(inc x) (inc y)]]) | |
(neighbours [2 2]) |