Questions & Results
Q1 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of the OCaml expression?
1 :: [2; 3]
D It produces a type error 138 / 175 answered · 91% correct
Q2 of 10Multiple ChoiceAccuracy60s · 1 pt
What happens when OCaml evaluates the following expression?
[1; "two"; 3]
A It evaluates to a list of length 3 B It produces a type error✓ Correct D It evaluates to a string list 150 / 175 answered · 95% correct
Q3 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of the OCaml expression?
[1; 2] @ [3; 4]
D It produces a type error 152 / 175 answered · 89% correct
Q4 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of f [4; 5; 6]?
let f lst =
match lst with
| [] → 0
| h :: t → h
158 / 175 answered · 94% correct
Q5 of 10Multiple ChoiceAccuracy60s · 1 pt
Which OCaml pattern matches ONLY lists with exactly two elements?
167 / 175 answered · 87% correct
Q6 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of the following OCaml expression?
match [1; 2; 3] with
| a :: b :: rest → a + b
| _ → 0
168 / 175 answered · 92% correct
Q7 of 10Multiple ChoiceAccuracy60s · 1 pt
What does OCaml report about the following definition?
let f lst =
match lst with
| h :: t → h
A Nothing; the match is exhaustive B A warning that the match is not exhaustive ([] is unmatched)✓ Correct C A type error, because h and t have different types D A warning that the h :: t branch is unused 173 / 175 answered · 91% correct
Q8 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the type of the OCaml function?
let f x lst = x :: lst
A 'a → 'a list → 'a list✓ Correct C 'a list → 'a list → 'a list D int → int list → int list 175 / 175 answered · 89% correct
Q9 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the type of the OCaml function?
let rec f lst =
match lst with
| [] → 0
| _ :: t → 1 + f t
173 / 175 answered · 76% correct
Q10 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the type of the OCaml function?
let rec f lst =
match lst with
| [] → []
| h :: t → (h * 2) :: f t
C int list → int list✓ Correct 175 / 175 answered · 75% correct
Score Distribution
Score (points) →