CMSC330-09/22

CMSC 330 — Fall 2026 · September 22, 2026 · 181 players · Max 10 pts

Questions & Results

Q1 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the type of add?

let add x y z = x + y + z
A int * int * int → int
3
B int → int → int → int
144
✓ Correct
C int → int
2
D int → int → int
4
153 / 181 answered · 94% correct
Q2 of 10Multiple ChoiceAccuracy60s · 1 pt

In OCaml, the application f 1 2 3 is equivalent to which expression?

A f (1, 2, 3)
14
B (f 1) (2 3)
1
C ((f 1) 2) 3
147
✓ Correct
D f (1 (2 3))
5
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
A 6
161
✓ Correct
B -6
10
C 10
D It produces a type error
2
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
A bool
2
B int → int → bool
36
C 'a → bool
9
D int → bool
123
✓ Correct
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
A 105
7
B 15
153
✓ Correct
C 110
1
D It produces an unbound variable error
10
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 ()
A 1
B 0
C 3
✓ Correct
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
A 14
129
✓ Correct
B 13
34
C 11
11
D 4
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
8
B let rec sum acc l = match l with [] → acc | h::t → sum (acc + h) t
152
✓ Correct
C let rec len l = match l with [] → 0 | _::t → 1 + len t
6
D let rec fact n = if n = 0 then 1 else n * fact (n - 1)
12
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
168
✓ Correct
B It reduces the number of recursive calls that are made
7
C It makes every recursive function run in O(1) time
3
D It allows recursion over infinite lists
2
180 / 181 answered · 93% correct
Q10 of 10Multiple ChoiceAccuracy60s · 1 pt

Which of List.fold_left and List.fold_right is tail recursive?

A Both of them
4
B Neither of them
1
C List.fold_right only
18
D List.fold_left only
156
✓ Correct
179 / 181 answered · 87% correct

Score Distribution

1
1
5
3
3
13
15
35
44
61
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
181
Average Score
7.4
High Score
9
Max Possible
10