One-dimensional cellular automata: Difference between revisions

Content added Content deleted
m (removed duplicated line: <lang algol68>INT stop generation = 9;)
(→‎{{header|Haskell}}: Dropped liftM2 and ap for the more current Applicatiive liftA2 and <*>)
Line 2,321: Line 2,321:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.List (unfoldr)
<lang haskell>import System.Random (newStdGen, randomRs)
import System.Random (newStdGen, randomRs)
import Control.Applicative (liftA2)
import Control.Monad (liftM2, ap)
import Data.List (unfoldr)


bnd :: String -> Char
bnd :: String -> Char
Line 2,345: Line 2,345:
lahmahgaan xs =
lahmahgaan xs =
init .
init .
until (liftM2 (==) last (last . init)) (ap (++) (return . donxt . last)) $
until (liftA2 (==) last (last . init)) ((++) <*> (return . donxt . last)) $
[xs, donxt xs]
[xs, donxt xs]