Ch 02 Quiz 2
-
I know the alphabet backwards. Make it.
"zyxwvutsrqponmlkjihgfedcba"
-
Make a list of the multiples of 20 between 105 and 231.
-
Make a function
q3
so thatq3 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]
-
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]
-
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 formula2x+3y
. -
In this problem the function f is defined by f(y) = (y-4)^2. Write a function
q6
that takes in a list of numbersys
. The output ofq6
is a list of (index ofy
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.