module Exercise01 where import Test.QuickCheck {-H1.1a)-} myPair :: Integer -> Integer -> Integer myPair x y = 2 ^ y * (2 * x + 1) - 1 {-H1.1b)-} mySnd :: Integer -> Integer mySnd p = div2 p 0 where div2 :: Integer -> Integer -> Integer div2 p y | even p = y | odd p = div2 (div p 2) $ y + 1 {-H1.1c)-} myFst :: Integer -> Integer myFst p | even p = div p 2 | odd p = myFst $ div p 2 {-H1.1d)-} prop_myPair :: Integer -> Integer -> Integer -> Property prop_myPair p x y = p > 0 && x > 0 && y > 0 ==> p == myPair x y {-H2-} digitToEo :: Integer -> String digitToEo 0 = "nul" digitToEo 1 = "unu" digitToEo 2 = "du" digitToEo 3 = "tri" digitToEo 4 = "kvar" digitToEo 5 = "kvin" digitToEo 6 = "ses" digitToEo 7 = "sep" digitToEo 8 = "ok" digitToEo 9 = "nau" {-WETT-} numberToEo :: Integer -> String numberToEo 0 = "nul" numberToEo n = tail $ n2E n 0 where n2E 1 3 = " mil" n2E n i | n > 999 = n2E (div n 1000) (i + 3) ++ n2E (mod n 1000) i | otherwise = n2E3d n 0 ++ position n i where n2E3d 0 _ = "" n2E3d n i = n2E3d (div n 10) (i + 1) ++ if d /= 0 then " " ++ (if d /= 1 || i == 0 then digitToEo d else "") ++ position n i else "" where d = mod n 10 position n i | n == 0 || i == 0 = "" | i == 1 = "dek" | i == 2 = "cent" | i == 3 = " mil" | otherwise = " " ++ ( if i > 9 then numberToEo $ div i 6 else "m" ) ++ ( if mod i 6 == 0 then "iliono" else "iliardo" ) ++ ( if n /= 1 then "j" else "" ) pr :: [String] -> IO () pr [] = print "" pr i = do print $ head i pr $ tail i {-TTEW-}