One-dimensional cellular automata: Difference between revisions

Add Seed7 example
m (→‎{{header|Java}}: Forgot the output)
(Add Seed7 example)
Line 1,872:
(0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
(0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)</lang>
 
=={{header|Seed7}}==
A graphical cellular automaton can be found [http://seed7.sourceforge.net/algorith/graphic.htm#cellauto here].
 
<lang seed7>$ include "seed7_05.s7i";
 
const string: start is "_###_##_#_#_#_#__#__";
const proc: main is func
local
var string: g0 is start;
var string: g1 is start;
var integer: generation is 0;
var integer: i is 0;
begin
writeln(g0);
for generation range 0 to 9 do
for i range 2 to pred(length(g0)) do
if g0[i-1] <> g0[i+1] then
g1 @:= [i] g0[i];
elsif g0[i] = '_' then
g1 @:= [i] g0[i-1];
else
g1 @:= [i] '_'
end if;
end for;
writeln(g1);
g0 := g1;
end for;
end func;</lang>
 
Output:
<pre>
_###_##_#_#_#_#__#__
_#_#####_#_#_#______
__##___##_#_#_______
__##___###_#________
__##___#_##_________
__##____###_________
__##____#_#_________
__##_____#__________
__##________________
__##________________
__##________________
</pre>
 
=={{header|Tcl}}==
<lang tcl>proc evolve {a} {