One-dimensional cellular automata: Difference between revisions
m
→{{header|Haskell}}: Applied Ormolu, preferred putStrLn to print, updated output.
m (→{{header|Haskell}}: Applied Ormolu, preferred putStrLn to print, updated output.) |
|||
Line 2,524:
=={{header|Haskell}}==
<lang haskell>import
import
bnd :: String -> Char
Line 2,531:
bnd "#_#" = '#'
bnd "##_" = '#'
bnd
nxt :: String -> String
Line 2,541:
lahmahgaan :: String -> [String]
lahmahgaan xs =
init
init . until ((==) . last <*> (last . init)) ((<>) <*> (return . nxt . last)) $▼
((==) . last <*> (last . init))
$ [xs, nxt xs]
main :: IO ()
Line 2,548 ⟶ 2,551:
g <- newStdGen
let oersoep = map ("_#" !!) . take 36 $ randomRs (0, 1) g
mapM_
{{Out}}
For example:
_#_##______#_#_#####_#_____###____##
___#_________#_#___##_____________##
______________#____##_____________##
___________________##_____________##</pre>
=={{header|Icon}} and {{header|Unicon}}==
|