Elementary cellular automaton/Random number generator: Difference between revisions

→‎{{header|Python}}: Add another eca generator.
(fix description of bit ordering)
(→‎{{header|Python}}: Add another eca generator.)
Line 71:
 
=={{header|Python}}==
===Python: With zero padded ends===
<lang python>from elementary_cellular_automaton import eca, eca_wrap
 
def rule30bytes(lencells=100):
Line 85 ⟶ 86:
<pre>[255, 255, 255, 255, 255, 255, 255, 255, 255, 255]</pre>
!
 
===Python: With wrapping of end cells===
<lang python>def rule30bytes(lencells=100):
cells = '1' + '0' * (lencells - 1)
gen = eca_wrap(cells, 30)
while True:
yield int(''.join(next(gen)[0] for i in range(8)), 2))</lang>
 
{{out}}
<pre>[220, 197, 147, 174, 117, 97, 149, 171, 240, 241]</pre>
 
=={{header|Tcl}}==
Anonymous user