! Cells in the next generation of the array are calculated based
! on the value of the cell and its left and right nearest
-! neighbours in the current generation. If, in the following
+! neighbors in the current generation. If, in the following
! table, a live cell is represented by 1 and a dead cell by 0 then
! to generate the value of the cell at a particular index in the
! array of cellular values you use the following table:
! 000 -> 0 #
! 001 -> 0 #
-! 010 -> 0 # Dies without enough neighbours
-! 011 -> 1 # Needs one neighbour to survive
+! 010 -> 0 # Dies without enough neighbors
+! 011 -> 1 # Needs one neighbor to survive
! 100 -> 0 #
-! 101 -> 1 # Two neighbours giving birth
-! 110 -> 1 # Needs one neighbour to survive
+! 101 -> 1 # Two neighbors giving birth
+! 110 -> 1 # Needs one neighbor to survive
! 111 -> 0 # Starved to death.
: bool-sum ( bool1 bool2 -- sum )
[ [ 2 ] [ 1 ] if ]
[ [ 1 ] [ 0 ] if ] if ;
-:: neighbours ( index world -- # )
+:: neighbors ( index world -- # )
index [ 1 - ] [ 1 + ] bi [ world ?nth ] bi@ bool-sum ;
-: count-neighbours ( world -- neighbours )
- [ length <iota> ] keep [ neighbours ] curry map ;
+: count-neighbors ( world -- neighbours )
+ [ length <iota> ] keep [ neighbors ] curry map ;
-: life-law ( alive? neighbours -- alive? )
+: life-law ( alive? neighbors -- alive? )
swap [ 1 = ] [ 2 = ] if ;
: step ( world -- world' )
- dup count-neighbours [ life-law ] ?{ } 2map-as ;
+ dup count-neighbors [ life-law ] ?{ } 2map-as ;
: print-cellular ( world -- )
[ CHAR: # CHAR: _ ? ] "" map-as print ;