From 01a7c86a05d2b94e2593ff1b01620792582eb622 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Thu, 20 Jul 2017 20:44:10 -0700 Subject: [PATCH] Update conway.hy to work with hy 0.13 --- conway.hy | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/conway.hy b/conway.hy index 7cd8ced..8aefeae 100644 --- a/conway.hy +++ b/conway.hy @@ -17,19 +17,18 @@ (!= (, (+ x dx) (+ y dy)) (, x y))))) (defn step [world] - (let [[new-world (.copy grid.Torus world)]] - (for [x (range new-world.width)] - (for [y (range new-world.height)] - (let [[cell (get! new-world x y)] - [ns (neighbours world x y)]] - (if (= cell 1) - (cond [(< ns 2) (set! new-world x y 0)] - [(or (= ns 2) (= ns 3)) (set! new-world x y 1)] - [(> ns 3) (set! new-world x y 0)]) - (cond [(= ns 3) (set! new-world x y 1)] - [True (set! new-world x y 0)]))))) - new-world)) - + (setv new-world (.copy grid.Torus world)) + (for [x (range new-world.width)] + (for [y (range new-world.height)] + (setv cell (get! new-world x y) + ns (neighbours world x y)) + (if (= cell 1) + (cond [(< ns 2) (set! new-world x y 0)] + [(or (= ns 2) (= ns 3)) (set! new-world x y 1)] + [(> ns 3) (set! new-world x y 0)]) + (cond [(= ns 3) (set! new-world x y 1)] + [True (set! new-world x y 0)])))) + new-world) ;; Create a glider...