Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Exercise_3 where
- import Data.List
- import Test.QuickCheck
- {- Library DO NOT CHANGE -}
- type Picture = [[Char]]
- type PadNumbersFn = [Integer] -> [String]
- printPicture :: Picture -> IO ()
- printPicture [] = return ()
- printPicture (xs : xss) = do
- putStrLn xs
- printPicture xss
- pic = [".##.", ".#.#", ".###", "####"]
- export_prop_padNumbers :: PadNumbersFn -> [Integer] -> Property
- export_prop_padNumbers f xs = property $ prop_padNumbers f xs
- {- End Library -}
- {-HA3.1-}
- prop_padNumbers padNumbers xs = undefined :: Bool
- {-HA3.2-}
- wrapText :: Integer -> [String] -> String
- wrapText 0 ws = "\n"
- wrapText n [] = ""
- wrapText n [w] = " " ++ w
- wrapText n (w:ws)
- | toInteger(length w) > n = "\n" ++ wrapText (n-(toInteger(length w)+1))ws
- | otherwise = w ++ " " ++ wrapText (n - (toInteger(length w) + 1)) ws
- {-HA3.3-}
- stretch :: Picture -> Picture
- stretch [] = []
- stretch [x] = [y:y|y<-x]:[y:y|y<-x]
- stretch (a:pic) = stretch a : stretch pic
- {-HA3.4-}
- coalesce :: [(String, Integer)] -> [(String, Integer)]
- coalesce [] = []
- coalesce [x] = [x]
- coalesce ((a,b):(c,d):xs) | a == c = (a,(b+d)): coalesce((c,d):xs)
- | otherwise = coalesce((c,d):xs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement