One-dimensional cellular automata: Difference between revisions
Content added Content deleted
(add FreeBASIC) |
(→{{header|Haskell}}: Minor tidying) |
||
Line 2,373: | Line 2,373: | ||
bnd :: String -> Char |
bnd :: String -> Char |
||
bnd |
bnd "_##" = '#' |
||
⚫ | |||
case bs of |
|||
bnd "##_" = '#' |
|||
bnd _ = '_' |
|||
⚫ | |||
_ -> '_' |
|||
nxt :: String -> String |
|||
nxt = unfoldr go . ('_' :) . (<> "_") |
|||
donxt xs = |
|||
where |
|||
⚫ | |||
(\xs -> |
|||
go xs = Just (bnd $ take 3 xs, drop 1 xs) |
|||
⚫ | |||
_ -> Just (bnd $ take 3 xs, drop 1 xs)) $ |
|||
'_' : xs ++ "_" |
|||
lahmahgaan :: String -> [String] |
lahmahgaan :: String -> [String] |
||
lahmahgaan xs = |
lahmahgaan xs = |
||
⚫ | |||
init . |
|||
⚫ | |||
⚫ | |||
⚫ | |||
main :: IO () |
main :: IO () |