Anonymous user
Elementary cellular automaton: Difference between revisions
→{{header|Perl 6}}: Combine the two solutions into one, and improve. (Hyper ops understand precedence and seem faster than X Z.)
m (→{{header|Sidef}}: modified the code to work with Sidef 2.30) |
(→{{header|Perl 6}}: Combine the two solutions into one, and improve. (Hyper ops understand precedence and seem faster than X Z.)) |
||
Line 969:
<lang perl6>class Automaton {
has
has @.cells;▼
method gist { <| |>.join: @!cells.map({+$_ ?? '#' !! ' '}).join }▼
method succ {
self.new: :$!rule, :@!code, :cells(
]
)
Line 984 ⟶ 988:
my $size = 10;
my Automaton $a .= new:
:rule(30),
:cells( flat 0 xx $size, 1, 0 xx $size );
say $a++ for ^$size;</lang>
{{out}}
<pre>
| ### |
| ## # |
Line 998 ⟶ 1,006:
| ## #### ###### |
| ## # ### # |
| ## #### ## # ### |
</pre>
▲ has @.cells;
▲ 2 * @!cells[i] +
▲ }
=={{header|Python}}==
|