Created
October 25, 2016 17:38
-
-
Save teodorlu/b5b19dfad23cb1c9b9c44e085a6f5e4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Text.Printf(printf) | |
pad :: Int -> Char -> String -> String | |
pad newlength padchar s = | |
let extraLength = max 0 (newlength - length s) | |
extraChars = take extraLength $ repeat padchar | |
in extraChars ++ s | |
makeAdress :: (Int, Int) -> Int -> String | |
makeAdress (startyr, endyr) issue = | |
printf "http://hybrida.no/upc/files/updatek/%d-%d/%s-%s.pdf" startyr endyr (mkCompactYrs startyr endyr) (pad 2 '0' (show issue)) | |
where mkCompactYrs a b = (keep 2 (show a)) ++ (keep 2 (show b)) | |
keep x s = drop (length s - x) s | |
includeNext x = (x, x + 1) | |
adresses :: [String] | |
adresses = do | |
year <- map includeNext [2012, 2014] | |
issue <- [0..12] | |
return $ makeAdress year issue | |
main = mapM_ putStrLn adresses |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment