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.
Warning! The page was not fully loaded, probably because of a network issue. It could be that not all functionalities work as expected. Please try reloading the page.
Haskell exercise
Tetris checkRow
Sign in to hand in your solution and get feedback.
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)