| CS 330 | Home | Schedule | Resources |
Estimated time: 2 hours
The objective of this homework is to
f(a X Y) = f(A x Y)
3=X
Foo=proc {$ X Y} X=Y end
local N in
N=true
if N then 0 else 1 end
end
local A in
local C in
A=a
C=c
case s(1:A 3:C) of s(1:X 3:Y) then {Browse X}
else {Browse 'else'} end
end
end
proc {P X}
if X>0 then {P X-1} end
end
Is the second occurrence of the identifier P free or bound? Justify your answer. Hint:
this is easy to answer if you first translate to kernel syntax.
declare MulByN A=10 B N in
N=3 % *
proc {MulByN X ?Y} % *
Y=N*X % *
end % *
{MulByN A B}
{Browse B}
What value, if any, is printed in the Browser? Now modify the code so that the lines marked with an asterik form the body of a local statement that declares a new identifier N. Consider two scenarios: one where the identifier N is removed from the declare line, and another where it remains and is bound to 4. How does the overall execution change? Explain why in terms of what is happening to the environment when MulByN is called.