PLQ #3Done on:   Tuesday, February 8th

Question 1 @ 2022-02-08 18:34

Examine the eval function below, which operates directly on the given S-expression instead of parsing it into an AST first.

(define (eval sexpr)
  (match sexpr
    [(number: n) n]
    [(list '+ left right) (+ (eval left) (eval right))]
    [(list '- left right) (- (eval left) (eval right))]
    [else (error 'eval "bad syntax in ~s" sexpr)]))

Which of the following statement(s) is true?

Question 2 @ 2022-02-08 18:36

We defined substitution using which of the following terms?

(Choose all of the relevant terms)

Question 3 @ 2022-02-08 18:40

Which should be a correct way of computing substitution?

Starting from:

{with {x {+ 5 5}} {+ x x}}

Question 4 @ 2022-02-08 18:42

How would we interpret this: e[v/x]

Question 5 @ 2022-02-08 18:43

What would this evaluate to?

{with {x y} 7}

If we were in our eager language, that would lead to a runtime error about y being unbound. But how would that change if we were using a lazy implementation (not evaluate the named expression)?