Which of the following expressions are constant-space loops in the CEK machine?
(Yf . x . fx) 0
(Yf . x . if0x (f 10) (f (-x 1))) 0
(Yf . x . if0x (f 10) (- (fx) 1)) 0
mk-odd = f . x . if0xfalse (not (f (-x 1)))odd = Ymk-odd(oddn) for any n
mk-oe = f . z . x . if0xz (f (notz) (-x 1))odd = Yf . mk-oeffalse(oddn) for any n
The extension of CEK with continuations that was presented in class (see the SECD handout) could be more efficient with simple changes. For example, the cc form of continuations needlessly keeps a sub-continiation that is never used.Suggest revisions to the K grammar and the reduction rules to streamline the machine.
Somewhat difficult. Collaboration is encouraged.Given:
next = k . x . (cck (mk-pairkx))
call = f . y . (f (next (fsty)) (sndy))
Z = f . x . (callf (letcck (mk-pairkx)))
What is the value of (Zmk-odd 1)?Justify your answer, but don't try to write down a complete CEK reduction.
Optional challenge (difficult).Define callcc as
callcc = f . (letcck (f (v . (cckv))))
What does ((callcccallcc) (callcccallcc)) do? Justify your answer.
Optional challenge (especially difficult).Does
((callcccallcc) (callcccallcc)) consume an arbitrarily large amount of "memory"? Justify your answer.Does
((y . ((callcccallcc) y)) (callcccallcc)) consume an arbitrarily large amount of "memory"? Justify your answer.
Last update: Tuesday, February 8th, email@example.com