Ch 02 Quiz 2

  1. I know the alphabet backwards. Make it.

     "zyxwvutsrqponmlkjihgfedcba"
    
  2. Make a list of the multiples of 20 between 105 and 231.

  3. Make a function q3 so that q3 a b produces a list with all of the multiples of 17 in the closed interval from a to b.

     q3 :: Int -> Int -> [Int]
     q3 a b = ...
     q3 17 51 == [17, 34, 51]
    
  4. Make a function that returns a list of all of the odd numbers in its input.

     q4 :: [Int] -> [Int]
     q4 xs = ...
     q4 [10,11,13,20,29] == [11,13,29]
    
  5. Make a list of ordered triples (x,y,z) where both x and y range through all of the integers in the closed interval from 0 to 10, and z comes from the formula 2x+3y.

  6. In this problem the function f is defined by f(y) = (y-4)^2. Write a function q6 that takes in a list of numbers ys. The output of q6 is a list of (index of y in the input list, y, function f applied to y).

    Examples:

    • q6 [10,3] == [(1,10,36), (2,3,1)]
    • q6 [50,60,65] == [(1,50,46^2), (2,60,56^2), (3,65,61^2)]

    Of course, Haskell will do the math so the third coordinates will actually be 2116, 3136, and 3721, but that makes it harder to understand the pattern.

Last modified August 18, 2023: 2022-2023 End State (7352e87)