One-dimensional cellular automata: Difference between revisions

→‎Python :: Composition of pure functions: Adjusted one value name for legibility
(→‎{{header|Python}}: Added a generalised variant (any Wolfram rule) constructed as a composition of pure functions.)
(→‎Python :: Composition of pure functions: Adjusted one value name for legibility)
Line 4,018:
 
# nextRowByRule :: Int -> [Bool] -> [Bool]
def nextRowByRule(nintRule):
'''A row of booleans derived by Wolfram rule n
from another boolean row of the same length.'''
Line 4,024:
# step :: (Bool, Bool, Bool) -> Bool
def step(l, x, r):
return bool(nintRule & 2**intFromBools([l, x, r]))
 
# go :: [Bool] -> Bool
9,659

edits