Elementary cellular automaton/Random number generator: Difference between revisions

Content added Content deleted
(correction : rule 30 is not used by Mathematica anymore for RNG)
(→‎{{header|Raku}}: use `handles <AT-POS>`)
Line 810: Line 810:
<syntaxhighlight lang="raku" line>class Automaton {
<syntaxhighlight lang="raku" line>class Automaton {
has $.rule;
has $.rule;
has @.cells;
has @.cells handles <AT-POS>;
has @.code = $!rule.fmt('%08b').flip.comb».Int;
has @.code = $!rule.fmt('%08b').flip.comb».Int;
Line 828: Line 828:
my Automaton $a .= new: :rule(30), :cells( flat 1, 0 xx 100 );
my Automaton $a .= new: :rule(30), :cells( flat 1, 0 xx 100 );


say :2[$a++.cells[0] xx 8] xx 10;</syntaxhighlight>
say :2[$a++[0] xx 8] xx 10;</syntaxhighlight>
{{out}}
{{out}}
<pre>220 197 147 174 117 97 149 171 240 241</pre>
<pre>220 197 147 174 117 97 149 171 240 241</pre>