Part 18

Quiz

What is the type of swap . swap?

  1. (a, b) -> (a, b)
  2. (a, b) -> (b, a)
  3. a -> a

What is the type of \f g x -> (f x, g x)?

  1. (a -> b) -> (c -> d) -> (a,c) -> (b, d)
  2. (a -> b) -> (a -> c) -> a -> (b, c)
  3. (a -> b) -> (b -> a) -> a -> (b, a)

What is the type of \t -> (fst . fst $ t, (snd . fst $ t, snd t))?

  1. (a, (b, c)) -> (a, (b, c))
  2. (a, (b, c)) -> ((a, b), c)
  3. ((a, b), c) -> (a, (b, c))

What does the function foldr (\x xs -> xs ++ [x]) [] do?

  1. It doesn’t change its input list at all
  2. It changes the associativity of a list from left to right
  3. It reverses its input list

What does the function foldr (\(x, y) zs -> x : y : zs) [] do?

  1. It turns a list of pairs into a pair of lists
  2. It turns a pair of lists into a list of pairs
  3. It turns a list of pairs into a list of elements

What is the type of foldr (\n b -> n == 3 && b)?

  1. (Foldable t, Eq a, Num a) => Bool -> t a -> Bool
  2. (Foldable t, Eq a, Num a, Bool b) => b -> t a -> b
  3. (Foldable t, Eq a, Num a) => Bool -> [ a ] -> Bool

What is the type of \x -> case x of (True, "Foo") -> show True ++ "Foo"?

  1. Either Bool String -> String
  2. (Bool, String) -> String
  3. Show a => (Bool, String) -> a
You have reached the end of this section!

You can check your current points from the blue blob in the bottom-right corner of the page.