Elementary cellular automaton/Random number generator: Difference between revisions
Elementary cellular automaton/Random number generator (view source)
Revision as of 22:30, 26 July 2021
, 2 years ago→{{header|Haskell}}: Minor reduction. Applied Ormolu.
No edit summary |
m (→{{header|Haskell}}: Minor reduction. Applied Ormolu.) |
||
Line 221:
Assume the comonadic solution given at [[Elementary cellular automaton#Haskell]] is packed in a module <code>CellularAutomata</code>
<lang Haskell>import CellularAutomata (
import Data.List (unfoldr)▼
import Control.Comonad
▲import Data.List (unfoldr)
rnd = fromBits <$> unfoldr (pure . splitAt 8) bits
where
size = 80
bits = extract <$> runCA (rule 30) (fromList (1:replicate size 0))▼
bits =
extract
<$> runCA
(rule 30)
fromBits = foldl (
{{Out}}
|