Anonymous user
One-dimensional cellular automata: Difference between revisions
→{{header|Perl 6}}: Update (GLR) and improve clarity
m (→{{header|Sidef}}: modified the code to work with Sidef 2.30) |
(→{{header|Perl 6}}: Update (GLR) and improve clarity) |
||
Line 3,225:
and it makes the implementation a lot easier.
<lang perl6>class
has
has @.cells;
method gist { <| |>.join: @!cells.map({$_ ?? '#' !! ' '}).join }▼
method succ {
)
▲ )
}
}</lang>
Line 3,242 ⟶ 3,245:
The rule proposed for this task is rule 0b01101000 = 104
<lang perl6>my
my
;
say $a++ for ^10;</lang>
{{out}}
<pre>
| # ##### # # |
| ## ## # |
Line 3,257 ⟶ 3,263:
| ## |
| ## |
| ## |
</pre>
Rule 104 is not particularly interesting so here is [[wp:Rule 90|Rule 90]],
which shows a [[wp:Sierpinski Triangle|Sierpinski Triangle]].
<lang perl6>my
my
say $a++ for ^20;</lang>
{{out}}
<pre>
| # # |
| # # |
Line 3,287 ⟶ 3,295:
| # # # # |
| # # # # |
| # # # # # # # # |
</pre>
=={{header|Phix}}==
|