Questions & Results
Q1 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the type of add?
let add x y z = x + y + z
B int → int → int → int✓ Correct 153 / 181 answered · 94% correct
Q2 of 10Multiple ChoiceAccuracy60s · 1 pt
In OCaml, the application f 1 2 3 is equivalent to which expression?
167 / 181 answered · 88% correct
Q3 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of the OCaml expression?
let sub x y = x - y in
let g = sub 10 in
g 4
D It produces a type error 173 / 181 answered · 93% correct
Q4 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the type of the OCaml expression?
(fun x y → x = y) 3
170 / 181 answered · 72% correct
Q5 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of f 5?
let x = 10
let f y = x + y
let x = 100
D It produces an unbound variable error 171 / 181 answered · 89% correct
Q6 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of the last expression?
let make_counter () =
let count = ref 0 in
fun () → count := !count + 1; !count
let c = make_counter () in
let _ = c () in
let _ = c () in
c ()
D It produces a type error 0 / 181 answered
Q7 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of a (b 1)?
let make_adder n = fun x → x + n
let a = make_adder 3
let b = make_adder 10
174 / 181 answered · 74% correct
Q8 of 10Multiple ChoiceAccuracy60s · 1 pt
Which of these functions is tail recursive?
A let rec sum l = match l with [] → 0 | h::t → h + sum t B let rec sum acc l = match l with [] → acc | h::t → sum (acc + h) t✓ Correct C let rec len l = match l with [] → 0 | _::t → 1 + len t D let rec fact n = if n = 0 then 1 else n * fact (n - 1) 178 / 181 answered · 85% correct
Q9 of 10Multiple ChoiceAccuracy60s · 1 pt
Why does OCaml optimize tail calls?
A It lets a recursive function run in constant stack space✓ Correct B It reduces the number of recursive calls that are made C It makes every recursive function run in O(1) time D It allows recursion over infinite lists 180 / 181 answered · 93% correct
Q10 of 10Multiple ChoiceAccuracy60s · 1 pt
Which of List.fold_left and List.fold_right is tail recursive?
D List.fold_left only✓ Correct 179 / 181 answered · 87% correct
Score Distribution
Score (points) →