CMSC330_11/03

CMSC 330 — Fall 2026 · November 03, 2026 · 183 players · Max 10 pts

Questions & Results

Q1 of 10Multiple ChoiceAccuracy45s · 1 pt

Using the environment-based interpreter with conditionals, what does this evaluate to?

if eq0 1 then 1 + true else 10
A It raises TypeError: + expects integers
87
B Int 10
64
✓ Correct
C Int 11
3
D Bool false
154 / 183 answered · 42% correct
Q2 of 10Multiple ChoiceAccuracy45s · 1 pt

Under static (lexical) scoping, what does this evaluate to?

A; fun x -> e ⇒ ?
A (•, λx.e)
11
B The value of e in A
18
C (A, λx.e)
120
✓ Correct
D e{A/x}
8
157 / 183 answered · 76% correct
Q3 of 10Multiple ChoiceAccuracy75s · 1 pt

Using the static-scoping eval, what does this return?

eval [("y", Int 5)] (Fun ("x", Plus (Ident "x", Ident "y")))
A Int 5
4
B Closure ([], "x", Plus (Ident "x", Ident "y"))
26
C It raises Failure "undefined: x"
11
D Closure ([("y", Int 5)], "x", Plus (Ident "x", Ident "y"))
134
✓ Correct
175 / 183 answered · 77% correct
Q4 of 10Multiple ChoiceAccuracy75s · 1 pt

With static scoping (as in OCaml), what does this evaluate to?

let x = 1 in
let f = fun y -> x + y in
let x = 10 in
f 5
A 6
168
✓ Correct
B 15
6
C 11
2
D It raises Failure "undefined: x"
3
179 / 183 answered · 94% correct
Q5 of 10Multiple ChoiceAccuracy75s · 1 pt

With dynamic scoping (eval_dyn), what does this evaluate to?

let x = 1 in
let f = fun y -> x + y in
let x = 10 in
f 5
A 6
1
B 11
6
C It raises Failure "undefined: x"
2
D 15
171
✓ Correct
180 / 183 answered · 95% correct
Q6 of 10Multiple ChoiceAccuracy45s · 1 pt

How is the judgment

G ⊢ e : t

read?

A e evaluates to the value t in environment G
32
B e is parsed into t using grammar G
12
C e has type t in context G
131
✓ Correct
D t is the environment after evaluating e
1
176 / 183 answered · 74% correct
Q7 of 10Multiple ChoiceAccuracy45s · 1 pt

How does a typing context G differ from an evaluation environment A?

A G maps variables to types; A maps variables to values
160
✓ Correct
B G maps types to variables; A maps values to variables
14
C G holds closures; A holds types
3
D There is no difference
1
178 / 183 answered · 90% correct
Q8 of 10Multiple ChoiceAccuracy45s · 1 pt

Which expression is ill-typed?

A 0 + 1
1
B let x = 3 in x + 1
9
C if eq0 0 then 1 else 2
3
D 1 + (if true then 0 else false)
163
✓ Correct
176 / 183 answered · 93% correct
Q9 of 10Multiple ChoiceAccuracy60s · 1 pt

In context x:int, y:bool, what is the type of this expression?

if y then x else x + 1
A int
139
✓ Correct
B bool
1
C Type error: x is int but y is bool
4
D bool -> int
36
180 / 183 answered · 77% correct
Q10 of 10Multiple ChoiceAccuracy45s · 1 pt

Which context lets us type check the expression x + (y + z)?

A • (the empty context)
4
B x:int
9
C x:int, y:int, z:int
166
✓ Correct
D x:int, y:bool, z:int
1
180 / 183 answered · 92% correct

Score Distribution

1
2
3
7
22
38
47
41
22
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
183
Average Score
7.7
High Score
10
Max Possible
10