PLQ #6Done on:   Tuesday, February 20th

Question 1 @ 2024-02-20 18:38

What is true about a syntactic evaluator?


Question 2 @ 2024-02-20 18:41

Consider the following code refactoring:

...
(let ([foo ...])
  ...)

=>

...
(define foo ...)
...

Is this a simple enough transformation that could be done by just regexp-replacing (assuming only simple one-lines as above) and re-indenting?

(Remember: choose the best answer.)


Question 3 @ 2024-02-20 18:44

Are the following two definitions of Y valid and equivalent?

(define Y1
  (lambda (f)
    ((lambda (x) (f (lambda (n) ((x x) n))))
    (lambda (x) (f (lambda (n) ((x x) n)))))))

(define Y2
  (lambda (f)
    ((lambda (x) (x x))
    (lambda (x) (f (lambda (n) ((x x) n)))))))

Question 4 @ 2024-02-20 18:47

We’ve seen how the core of the Y combinator leads to an inifinte nesting of calls to F:

((lambda (x) (x x))
(lambda (x) (F (x x))))
=>
(F (F (F ...)))

What would we get if we’d change it to:

((lambda (x) (G (x x)))
(lambda (x) (F (x x))))
=>
???

Question 5 @ 2024-02-20 18:50

What would you get if you evaluate the next expression in Schlac?

(define foo (lambda (x x) x))
(foo 1 2)