PLQ #3Done on:   Tuesday, February 9th

Question 1 @ 2021-02-09 18:20

Take the following WAE expression:

      \v/
{with {x x} x}
      /^\

Which kind of an identifier is the FIRST occurrence of x?


Question 2 @ 2021-02-09 18:22

Take the following WAE expression:

        \v/
{with {x x} x}
        /^\

Which kind of an identifier is the SECOND occurrence of x?


Question 3 @ 2021-02-09 18:24

Take the following WAE expression:

          \v/
{with {x x} x}
          /^\

Which kind of an identifier is the THIRD occurrence of x?


Question 4 @ 2021-02-09 18:25

The scope of an identifier…


Question 5 @ 2021-02-09 18:28

Last time, we have seen the implementation of the WAE evaluator, specifically, this was the evaluation fragment for with:

[(With bound-id named-expr bound-body)
(eval (subst bound-body
              bound-id
              (Num (eval named-expr))))]

We saw that there is a simple way to make it into a lazy binder. How do we do that?


Question 6 @ 2021-02-09 18:30

Alice has excited about intsets from HW#2, so she wrote some code to find out the length of a (normalized) set:

(: intset-length : INTSET -> Integer)
(define (intset-length set)
  (cases set
    [(Num n) 1]
    [(Range lhs rhs) (+ (- rhs lhs) 1)]
    [(2Sets lhs rhs) (+ (intset-length lhs) (intset-length rhs))]))

Bob says that Alice should add an else clause:

    [else (error "unexpected intset variant")]

Is this correct?