RosettaCodeData/Task/Elementary-cellular-automaton/Haskell/elementary-cellular-automaton-2.hs
2023-07-01 13:44:08 -04:00

6 lines
207 B
Haskell

rule n l x r = n `div` (2^(4*l + 2*x + r)) `mod` 2
initial n = listArray (0,n-1) . center . padRight n
where
padRight n lst = take n $ lst ++ repeat 0
center = take n . drop (n `div` 2+1) . cycle