Assume an array of cells with an initial distribution of live and dead cells,
and imaginary cells off the end of the array having fixed values.

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 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
100 -> 0  #
101 -> 1  # Two neighbours giving birth
110 -> 1  # Needs one neighbour to survive
111 -> 0  # Starved to death.

/*REXX program generates & displays N generations of one─dimensional cellular automata. */
parse arg $ gens .                               /*obtain optional arguments from the CL*/
if    $=='' |    $==","  then $=001110110101010  /*Not specified?  Then use the default.*/
if gens=='' | gens==","  then gens=40            /* "      "         "   "   "     "    */
 
   do #=0  for gens                              /* process the  one-dimensional  cells.*/
   say  " generation"    right(#,length(gens))       ' '       translate($, "#·", 10)
   @=0                                                                /* [↓] generation.*/
          do j=2  for length($) - 1;          x=substr($, j-1, 3)     /*obtain the cell.*/
          if x==011 | x==101 | x==110  then @=overlay(1, @, j)        /*the cell lives. */
                                       else @=overlay(0, @, j)        /* "   "    dies. */
          end   /*j*/
 
   if $==@  then do;  say right('repeats', 40);  leave;  end          /*does it repeat? */
   $=@                                           /*now use the next generation of cells.*/
   end       /*#*/                               /*stick a fork in it,  we're all done. */