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 154 / 183 answered · 42% correct
Q2 of 10Multiple ChoiceAccuracy45s · 1 pt
Under static (lexical) scoping, what does this evaluate to?
A; fun x -> e ⇒ ?
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")))
B Closure ([], "x", Plus (Ident "x", Ident "y")) C It raises Failure "undefined: x" D Closure ([("y", Int 5)], "x", Plus (Ident "x", Ident "y"))✓ 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
D It raises Failure "undefined: x" 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
C It raises Failure "undefined: x" 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 B e is parsed into t using grammar G C e has type t in context G✓ Correct D t is the environment after evaluating e 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✓ Correct B G maps types to variables; A maps values to variables C G holds closures; A holds types 178 / 183 answered · 90% correct
Q8 of 10Multiple ChoiceAccuracy45s · 1 pt
Which expression is ill-typed?
D 1 + (if true then 0 else false)✓ 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
C Type error: x is int but y is bool 180 / 183 answered · 77% correct
Q10 of 10Multiple ChoiceAccuracy45s · 1 pt
Which context lets us type check the expression x + (y + z)?
C x:int, y:int, z:int✓ Correct 180 / 183 answered · 92% correct
Score Distribution
Score (points) →