Last active
January 7, 2017 18:07
-
-
Save simonewebdesign/0f400700eb2f537c3e1703f4d9b4d700 to your computer and use it in GitHub Desktop.
Game of Life 2D list
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
# Game of life | |
# Goal is to have a 2D list that looks like: | |
[ [false, false, true, false, false], | |
[true, true, false, false, false], | |
... | |
] | |
# data is a list of coordinates {row, col} where {0,0} is the top-left origin | |
data = [{0,1}, {2,3}, {3,4}, {4,4}] | |
# Solution | |
for i <- 0..4 do | |
for j <- 0..4 do | |
a = for {^j, ^i} <- data do | |
true | |
end | |
case a do | |
[] -> false | |
[_] -> true | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment