Skip to content

Instantly share code, notes, and snippets.

@devinus
Forked from josevalim/def.exs
Created October 9, 2013 21:31
Show Gist options
  • Save devinus/6908791 to your computer and use it in GitHub Desktop.
Save devinus/6908791 to your computer and use it in GitHub Desktop.
def next_state do
(board, x, y) ->
cell = cell_at(board, x, y)
live_count = live_neighbors(board, x, y)
next_state(cell, live_count)
(_, x, y) when (x < 0 or y < 0) ->
"."
end
def next_state do
("o", live_count) when live_count in 2..3 -> "o"
("o", _) -> "."
(".", live_count) when live_count === 3 -> "o"
(".", _) -> "."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment