Last active
August 29, 2015 14:12
-
-
Save julienXX/03fa80ee8062d918aafb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Random | |
randomCells :: Int -> StdGen -> [Int] | |
randomCells size gen = take size $ randomRs (0, 1) gen | |
createGeneration :: [Int] -> Int -> [[Int]] -> [[Int]] | |
createGeneration [] _ generation = generation -- use _ when you don't use a variable | |
createGeneration cells width generation = | |
let line = take width cells | |
in createGeneration (drop width cells) width (line:generation) | |
main :: IO() -- declare type signature | |
main = | |
let cells = randomCells 12 (mkStdGen 123) | |
in print (createGeneration cells 4 []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment