One-dimensional cellular automata: Difference between revisions
Content deleted Content added
added C code |
|||
Line 570:
Generation 8: __##________________
Generation 9: __##________________</pre>
=={{header|Nial}}==
(life.nial)
% we need a way to write a values and pass the same back
wi is rest link [write pass, pass]
% calculate the neighbors by rotating the array left and right and joining them
neighbors is pack [pass, sum [-1 rotate, 1 rotate]]
% calculate the individual birth and death of a single array element
igen is fork [ = [ + [first, second], 3 first], 0 first, = [ + [first, second], 2 first], 1 first, 0 first ]
% apply that to the array
nextgen is each igen neighbors
% 42
life is fork [ > [sum pass, 0 first], life nextgen wi pass, pass ]
Using it
|loaddefs 'life.nial'
|I := [0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0]
|life I
=={{header|OCaml}}==
|