Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defrecord Point [x y])
- (defrecord Enviro [cells dims])
- (defn create-dead-enviro [width height]
- (Enviro.
- (replicate (* width height) :dead)
- (->Point width height)))
- (defn index-of [width x y]
- (+ (* y width) x))
- (defn enviro-index-of [enviro x y]
- (let [width (-> enviro :dims :x)]
- (index-of width x y)))
- (defn set-cell-at [enviro x y cell]
- (let [cells (:cells enviro)
- index (enviro-index-of enviro x y)]
- (assoc enviro :cells (assoc cells index cell))))
Advertisement
Add Comment
Please, Sign In to add comment