v[d:p] denote the lexical address of a variable
v in a
character syntax expression if it has depth d
and position p, and
v[F: ] if v
occurs free in the expression. Complete the following
conversions into lexical address expressions.
let c = 5
f = proc (x, y) +(x, y)
in
let c = 6
b = 7
g = proc (a, b)
proc (a)
(a b c)
in
((g 3 4) f)
=>
let c = 5
f = proc (x, y) +(x[0:0], y[0:1])
in
let c = 6
b = 7
g = proc (a, b)
proc (a)
(a[0:0] b[1:1] c[2:0])
in
((g[0:2] 3 4) f[1:1])
let a = 2
b = 3
in
let a = 4
p = proc (x) +(a, x)
in
let b = 5
q = proc (x, y) (p (y a))
in
(q b p)
=>
let a = 2
b = 3
in
let a = 4
p = proc (x) +(a[_:_], x[_:_])
in
let b = 5
q = proc (x, y) (p[_:_] (y[_:_] a[_:_]))
in
(q[_:_] b[_:_] p[_:_])
let c = 5
f = proc (x, y) +(x, y)
in
let c = 6
b = 7
g = proc (a, b)
proc (a)
(a b c)
in
((g 3 4) f)
=>
______
let a = 2
b = 3
in
let a = 4
p = proc (x) +(a, x)
in
let b = 5
q = proc (x, y) (p (y a))
in
(q b p)
=>
______
let c = 5
f = proc (x, y) +(x, y)
in
let c = 6
b = 7
g = proc (a, b)
proc (a)
(a b c)
in
((g 3 4) f)
=>
______
let a = 2
b = 3
in
let a = 4
p = proc (x) +(a, x)
in
let b = 5
q = proc (x, y) (p (y a))
in
(q b p)
=>
______
(extended-env-record
(i v x emptylist)
#4(1 5 10 ())
(empty-env-record))
what is printed and what is the value of the following expression?
let a = 2
in
let f = proc (x) *(a, add1(x))
in
let d = print(f)
in
(f x)
(closure
(_)
(primapp-exp
(________)
(_______________________________________________________))
(extended-env-record
(_)
#1(_)
(extended-env-record
(i v x emptylist)
#4(1 5 10 ())
(empty-env-record))))
______
else of the if in
letrec f(x) = if zero?(x)
then (g 3)
else +(x, (f -(x, 2)))
g(x) = *(x, x)
in
(f 2)
__________
else:
+-------+ |add-exp| +-------+ / \