PROBLEM 1 = = = = = 1. 1477 = 1477 :: Num a => a 2. 3+2 = 5 :: Num a => a 3. 15/2 = 7.5 :: Fractional a => a 4. div 15 2 = 7 :: Integral a => a 5. 15 `div` 2 = 7 :: Integral a => a 6. 15 div 2 = :11:1: (ERROR?) 7. 15.0 / 2.0 = 7.5 :: Fractional a => a 8. 15.0 `div` 2.0 = :13:1: No instance for (Fractional a0) arising from a use of ‘it’ (ERROR?) 9. 13.4 / 1.8 = 7.444444444444445 :: Fractional a => a 10. 2.71 > 5.67 = False :: Bool 11. "x" ++ "yz" = "xyz" :: [Char] 12. x ++ "yz" = :20:1: Not in scope: ‘x’ (ERROR?) 13. show 7 = "7" :: String 14. read "7" :: Integer = 7 :: Integer 15. truncate 23.6 = 23 :: Num a => a 16. take 4 "Computer Science!" = "Comp" :: [Char] 17. drop 4 "Computer Science!" = "uter Science!" :: [Char] 18. take 7 drop 9 "Computer Science!" = :30:1: Couldn't match expected type (ERROR?) 19. take 7 (drop 9 "Computer Science!") = "Science" :: [Char] 20. "kalle" >= "andersson" = True :: Bool 21. "anders" < "andersson" = True :: Bool 22. length "soffbord" = 8 :: Int 23. 2 >= 6 || 2.71 > 5.67 = False :: Bool 24. 2 >= 6 || 2.71 < 5.67 = True :: Bool 25. 65 < 150 || 19 = :37:13: No instance for (Num Bool) (ERROR?) 26. 1 `div` 0 < 3 && 2.0 < 1.0 = *** Exception: divide by zero 27. 2.0 < 1.0 && 1 `div` 0 < 3 = False :: Bool 28. not (2.71 > 5.67) = True :: Bool PROBLEM 2 = = = = = 1. / (/) :: Fractional a => a -> a -> a - division operator 2. div div :: Integral a => a -> a -> a 3. > (>) :: Ord a => a -> a -> Bool - greater-than operator 4. >= (>=) :: Ord a => a -> a -> Bool - greater-than-or-equal operator 5. || (||) :: Bool -> Bool -> Bool - OR operator 6. not not :: Bool -> Bool 7. ++ (++) :: [a] -> [a] -> [a] - concatenation operator 8. take take :: Int -> [a] -> [a] Hoogλe: take n, applied to a list xs, returns the prefix of xs of length n, or xs itself if n > length xs: > take 5 "Hello World!" == "Hello" > take 3 [1,2,3,4,5] == [1,2,3] > take 3 [1,2] == [1,2] > take 3 [] == [] > take (-1) [1,2] == [] > take 0 [1,2] == [] It is an instance of the more general Data.List.genericTake, in which n may be of any integral type. 9. drop drop :: Int -> [a] -> [a] Hoogλe: drop n xs returns the suffix of xs after the first n elements, or [] if n > length xs: > drop 6 "Hello World!" == "World!" > drop 3 [1,2,3,4,5] == [4,5] > drop 3 [1,2] == [] > drop 3 [] == [] > drop (-1) [1,2] == [1,2] > drop 0 [1,2] == [1,2] It is an instance of the more general Data.List.genericDrop, in which n may be of any integral type. 10. truncate truncate :: (Integral b, RealFrac a) => a -> b Hoogλe: truncate :: (RealFrac a, Integral b) => a -> b 11. length length :: Foldable t => t a -> Int Hoogλe: O(n). length returns the length of a finite list as an Int. It is an instance of the more general Data.List.genericLength, the result type of which may be any kind of number. PROBLEM 3 = = = = = 1. round 3.4 3 :: Integral b => b 2. (round)3.4 3 :: Integral b => b 3. round3.4 :62:1: Not in scope: 4. round 3.4 + 10.0 :63:1: No instance for (Fractional a0) 5. round(3.4 + 10.0) 13 :: Integral b => b 6. 1 + 2 * 3 7 :: Num a => a 7. (1 + 2) * 3 9 :: Num a => a 8. 3 * 2 + 1 7 :: Num a => a 9. (3 * 2) + 1 7 :: Num a => a 10. 7+6 13 :: Num a => a 11. 7 + 6 13 :: Num a => a 12. 17 `div` 3 5 :: Integral a => a 13. div (17 3) :72:1: Non type-variable argument in the constraint 14. not (not True) True :: Bool 15. (not not) True :75:1: Couldn't match expected type ‘Bool -> t’ with actual type ‘Bool’ :75:6: Couldn't match expected type ‘Bool’ with actual type ‘Bool -> Bool’ PROBLEM 4 = = = = = 1. let pi = 3.1415927 2. let radius = 5.0 3. let area = pi * radius * radius 4. area 78.5398175 :: Fractional a => a