(defn step-sugar[gridrange](let [count-neighbours;; determine number of neighbours(fn[[ij]](reduce + (map #(get-ingrid%0)(for[a[-101]b[-101]][(+ ia)(+ jb)]))))new-value;; calculate new value for cell(fn [v[ij]](let [c(- (count-neighbours[ij])v)](cond (= 3c)1(= 2c)v:else0)))evolve-cell;; update cell in a grid(fn[gi](update-ingi#(new-value%i)))](reduce evolve-cellgridrange)))
Actually, this version is cheating,
due to passing one extra-parameter range that contains all indices
need to be updated in form [[0 1] [1 1]]...
On the other side it gives us two features:
Works for rectangular grid. Although, initial
implementation assumes the world is square.
Specific part of world can be updated. It gives possibility
to update specific area in the world, for example west organisms evolve faster.