0% found this document useful (0 votes)
13 views3 pages

22 1 Midterm Sol

The document is a midterm exam for CS 320, Spring 2022, consisting of various questions related to programming concepts such as syntax, semantics, and evaluation strategies. It includes multiple-choice questions, coding problems, and theoretical questions, with specific point allocations for each part. The exam assesses students' understanding of functional programming and related topics.

Uploaded by

vedapac571
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

22 1 Midterm Sol

The document is a midterm exam for CS 320, Spring 2022, consisting of various questions related to programming concepts such as syntax, semantics, and evaluation strategies. It includes multiple-choice questions, coding problems, and theoretical questions, with specific point allocations for each part. The exam assesses students' understanding of functional programming and related topics.

Uploaded by

vedapac571
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Midterm Exam

CS 320, Spring 2022

1) (5pts)

a) (1pt) syntax
b) (1pt) semantics
c) (1pt) concrete syntax
d) (1pt) abstract syntax
e) (1pt) parser

2) (5pts)
a) (3pts) 3->1, 4->2, 7->6, 9->5, 10->8
b) (2pts) 1->5, 1->6, 5->8 (allowed to include also 1->8)
-1pt per missing ->. if there’s no missing one, -1pt per wrong ->

3) (5pts) { x => y }
4) (10pts)
a) (2pts) bindings(b) + x
b) (3pts) bindings(b) ++ bindings(e) + f + x
c) (2pts) frees(b) - x
d) (3pts) (frees(b) - f - x) ++ (frees(e) - f)
No partial credit for each subquestion

5) (10pts) App(
App(
Fun("x", Fun("y", Fun("z",
App(App(Id("z"), Id("x")), Id("y"))
))),
desugar(f)
),
desugar(s)
)
Lazy pair: -3pts
No desugar: -3pts
Minor mistake: -1pt

1
6) (5pts) max(0, (number of correct answers) − 2 × (number of wrong answers)) pts
a) error
b) 120
c) 120
d) 120
e) 120
7) (10pts)
a) (6pts) { x => box.get(x) } (2pts for box.get)
b) (3pts) f or b(f)
c) (1pt) f or b(f) or box.get or openbox(box) or b(box.get) or b(openbox(box)) or · · ·
8) (5pts) { x => x }({ x => x }(1)), [], []
{ x => x }, [], []
{ x => x }(1), [], []
{ x => x }, [], []
1, [], []
x, [x -> 1], [1 -> 1]
x, [x -> 2], [1 -> 1, 2 -> 1]
-1pt per wrong line
9) (10pts)
a) (2pts) (PtrV(env(x)), sto)
b) (4pts) val (pv, ps) = interp(p, env, sto)
(ps(getAddr(pv)), ps)

c) (4pts) val (pv, ps) = interp(p, env, sto)


val (ev, es) = interp(e, env, ps)
(ev, es + (getAddr(pv) -> ev))

10) (5pts) GWWW, BWGW, BWBG, BWBB or GWWW, GWGW, BWGW, BWGG, BWBG, BWBB
11) (15pts)
a) (9pts) heap(free) = heap(addr)
heap(free + 1) = heap(addr + 1)
heap(addr) = 99
heap(addr + 1) = free
free += 2
free - 2
b) (3pts) heap(addr + 1)
c) (3pts) heap(scan + 1) = copy(heap(scan + 1))

2
12) (5pts) { x => (x + x) }((1 + 2)), []
{ x => (x + x) }, [] (1pt)
(x + x), [x -> ((1 + 2), [])] (2pts)
x, [x -> ((1 + 2), [])] (1pt)
(1 + 2), [] (1pt)
1, []
2, []
x, [x -> ((1 + 2), [])]
(1 + 2), []
1, []
2, []
13) (10pts) σ`e⇒v σ ` e ⇒ v0 v0 ⇓ v
n⇓n hλx.e, σi ⇓ hλx.e, σi
a) (5pts) delay(e, σ) ⇓ v lazy(e, σ) ⇓ v
1pt 2pts 2pts
σ ` e ⇒ v0 v0 ⇓ v
σ ` delay e ⇒ delay(e, σ) σ ` lazy e ⇒ lazy(e, σ)
b) (5pts) σ ` force e ⇒ v
1pt 1pt 3pts

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy