Name: Anonymous 2012-04-30 23:37
Anybody up for some code golf? I'm bored and I want to abuse scripting languages...
import Data.List
groupsOf :: Int -> [a] -> [[a]]
groupsOf n xs = take (length xs' - n) xs'
where xs' = map (take n) (tails xs)
step :: [Bool] -> [Bool]
step xs = map next (groupsOf 3 xs')
where xs' = [False] ++ xs ++ [False]
next :: [Bool] -> Bool
next [True, True, True ] = False
next [True, False, False] = False
next [False, False, False] = False
next _ = True
rule110 :: [Bool] -> [[Bool]]
rule110 = iterate step
main :: IO ()
main = mapM_ putStrLn xs
where xs = map (map f) (rule110 $ replicate 49 False ++ [True])
f True = '#'
f False = ' '
v=.0<R(17 b.)2^#.|:(,.i:1)|.v