Elementary cellular automaton: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 3,771:
* * * * * * * *
* * * * * * * * * * * * * * * *
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">def Width = 32, Rule = 90; \ = %0101_1010
int Gen, Old, New, Shift, Triad;
[New:= 1<<(Width/2);
for Gen:= 0 to 15 do
[Old:= New;
repeat ChOut(0, if New&1 then ^* else ^ );
New:= New>>1;
until New = 0;
CrLf(0);
New:= 0; Shift:= 1;
repeat Triad:= Old & %111;
if Rule & 1<<Triad then
New:= New + 1<<Shift;
Old:= Old>>1;
Shift:= Shift+1;
until Shift >= Width;
];
]</syntaxhighlight>
{{out}}
<pre>
*
* *
* *
* * * *
* *
* * * *
* * * *
* * * * * * * *
* *
* * * *
* * * *
* * * * * * * *
* * * *
* * * * * * * *
* * * * * * * *
* * * * * * * * * * * * * * * *
</pre>
 
296

edits