Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Update conway.hy to work with hy 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
jgkamat committed Jul 21, 2017
1 parent 88c3c06 commit 01a7c86
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions conway.hy
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down

0 comments on commit 01a7c86

Please sign in to comment.