Warning! It seems that you are using Dodona within another webpage, so not everything may work properly. Let your teacher know so that he can solve the problem by adjusting a setting in the learning environment. In the meantime, you can click this link to open Dodona in a new window.
Tetris checkRow
Sign in to test your solution.
import Data.List
data Block = Block (Int,Int)
deriving (Eq,Show)
data Board = Board [Block]
deriving (Eq,Show)
onRow :: Int -> Block -> Bool
onRow y (Block (_,y2)) = y == y2
lower :: Int -> Block -> Block
lower y (Block (x,y2)) | y > y2 = Block (x,y2+1)
| otherwise = Block (x,y2)
-- Check whether the board has full lines
-- If we are at line 0 just return the board
-- If the board has a full line lower all the blocks above
-- otherwise check that the line below is full
-- (* Difficulty 2 *)
checkRow :: Int -> Board -> Board
checkRow 0 (Board b) = (Board b)
checkRow y (Board b) | length rowY == 10 = undefined
| otherwise = undefined
where rowY = (filter (onRow y) b)
You can submit as many times as you like. Only your latest submission will be taken into account.
Sign in to test your solution.