CMSC330-09/10

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

Questions & Results

Q1 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

1 :: [2; 3]

A [1; 2; 3]
125
✓ Correct
B [1; [2; 3]]
9
C [[1]; 2; 3]
1
D It produces a type error
3
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
7
B It produces a type error
143
✓ Correct
C It evaluates to [1; 3]
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]

A [1; 2; 3; 4]
135
✓ Correct
B [[1; 2]; [3; 4]]
17
C [1; 2]
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

A 0
3
B 4
148
✓ Correct
C 6
4
D [5; 6]
3
158 / 175 answered · 94% correct
Q5 of 10Multiple ChoiceAccuracy60s · 1 pt

Which OCaml pattern matches ONLY lists with exactly two elements?

A _ :: _
16
B [_]
1
C [_; _]
145
✓ Correct
D h :: t
5
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

A 0
9
B 1
1
C 3
154
✓ Correct
D 6
4
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
10
B A warning that the match is not exhaustive ([] is unmatched)
157
✓ Correct
C A type error, because h and t have different types
2
D A warning that the h :: t branch is unused
4
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
155
✓ Correct
B 'a → 'b list → 'b list
6
C 'a list → 'a list → 'a list
12
D int → int list → int list
2
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

A int list → int
38
B 'a list → int
131
✓ Correct
C 'a list → 'a
3
D 'a list → 'a list
1
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

A 'a list → 'a list
25
B int list → int
2
C int list → int list
131
✓ Correct
D 'a list → int list
17
175 / 175 answered · 75% correct

Score Distribution

1
6
6
6
11
5
13
24
46
57
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
175
Average Score
8.1
High Score
18
Max Possible
10