Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. module Exercise_3 where
  2.  
  3. import Data.List
  4. import Test.QuickCheck
  5.  
  6. {- Library DO NOT CHANGE -}
  7. type Picture = [[Char]]
  8. type PadNumbersFn = [Integer] -> [String]
  9.  
  10. printPicture :: Picture -> IO ()
  11. printPicture [] = return ()
  12. printPicture (xs : xss) = do
  13. putStrLn xs
  14. printPicture xss
  15.  
  16. pic = [".##.", ".#.#", ".###", "####"]
  17.  
  18. export_prop_padNumbers :: PadNumbersFn -> [Integer] -> Property
  19. export_prop_padNumbers f xs = property $ prop_padNumbers f xs
  20. {- End Library -}
  21.  
  22. {-HA3.1-}
  23.  
  24. prop_padNumbers padNumbers xs = undefined :: Bool
  25.  
  26. {-HA3.2-}
  27. wrapText :: Integer -> [String] -> String
  28. wrapText 0 ws = "\n"
  29. wrapText n [] = ""
  30. wrapText n [w] = " " ++ w
  31. wrapText n (w:ws)
  32. | toInteger(length w) > n = "\n" ++ wrapText (n-(toInteger(length w)+1))ws
  33. | otherwise = w ++ " " ++ wrapText (n - (toInteger(length w) + 1)) ws
  34.  
  35.  
  36. {-HA3.3-}
  37. stretch :: Picture -> Picture
  38. stretch [] = []
  39. stretch [x] = [y:y|y<-x]:[y:y|y<-x]
  40. stretch (a:pic) = stretch a : stretch pic
  41.  
  42. {-HA3.4-}
  43. coalesce :: [(String, Integer)] -> [(String, Integer)]
  44. coalesce [] = []
  45. coalesce [x] = [x]
  46. coalesce ((a,b):(c,d):xs) | a == c = (a,(b+d)): coalesce((c,d):xs)
  47. | otherwise = coalesce((c,d):xs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement