Advertisement
Coriic

Untitled

May 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.Map as Map
  2.  
  3. data Coordinates = Coordinates Int Int
  4.  
  5. instance Ord Coordinates  where
  6.     (Coordinates a b) `compare` (Coordinates c d)
  7.     |b == d = a `compare` c
  8.     |otherwise = b `compare` d
  9.  
  10. data Color = W | B
  11.  
  12. instance Show Color where
  13.    show W = "⚇"
  14.    show B = "⚉"
  15.  
  16. data Board = Board (Map Coordinates Color)
  17.  
  18. toString (Board board map)=
  19.     where list = [Coordinates x y | x <- [1..19], y <- [1..19]]
  20.         mapToCharacter (Coordinates coordinates) =
  21.             |member coordinates board = lookup coordinates map
  22.             |otherwise " "
  23.         iterate [element] = mapToCharacter element
  24.         iterate (listOfCoordinates:element) = (mapToCharacter element) ++ iterate(listOfCoordinates)
  25.     iterate(list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement