diff --git a/life.hs b/life.hs index 835d622..3afe060 100644 --- a/life.hs +++ b/life.hs @@ -3,6 +3,13 @@ import Matrix type Cell = Int type Grid = Mat Cell +-- | Print a grid +gprint :: Grid -> IO () +gprint = putStrLn . map replace . show + where + replace '1' = '■' + replace '0' = '.' + replace a = a -- | Get the state of a cell -- 0 when out of the grid @@ -31,7 +38,7 @@ next :: Grid -> Grid next g = fmap (alive g) (indeces g) main :: IO () -main = mapM_ print (iterate next grid) +main = mapM_ gprint (iterate next grid) grid = Mat [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]