You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
437 B
18 lines
437 B
defmodule Tetris.Bottom do |
|
def merge(bottom, points) do |
|
points |
|
|> Enum.map( fn {x, y, c} -> {{x, y }, {x, y, c}} end) |
|
|> Enum.into(bottom) |
|
end |
|
|
|
def collides?(bottom, {x,y, _colour}) do |
|
collides?(bottom, {x,y}) |
|
end |
|
def collides?(bottom, {x,y}) do |
|
!!Map.get(bottom, {x,y}) |
|
end |
|
def collides?(bottom, points) when is_list(points) do |
|
Enum.any?(points, &collides?(bottom,&1)) |
|
end |
|
|
|
end
|
|
|