PLQ #2Done on:   Tuesday, February 2nd

Question 1 @ 2021-02-02 19:11

The AE BNF is:

<AE> ::= <num>
      | { + <AE> <AE> }
      | { - <AE> <AE> }
      | { * <AE> <AE> }
      | { / <AE> <AE> }

Is this for a language that evaluates expressions left-to-right or right-to-left?


Question 2 @ 2021-02-02 19:25

Reminder: this is the code that we wrote last class to evaluate AE expressions:

(define (eval expr)
  (cases expr
    [(Num n)  n]
    [(Add l r) (+ (eval l) (eval r))]
    [(Sub l r) (- (eval l) (eval r))]
    [(Mul l r) (* (eval l) (eval r))]
    [(Div l r) (/ (eval l) (eval r))]))

Does this implement addition from left-to-right or right-to-left?


Question 3 @ 2021-02-02 19:37

Reminder: this is the code that we wrote last class to evaluate AE expressions:

(define (eval expr)
  (cases expr
    [(Num n)  n]
    [(Add l r) (+ (eval l) (eval r))]
    [(Sub l r) (- (eval l) (eval r))]
    [(Mul l r) (* (eval l) (eval r))]
    [(Div l r) (/ (eval l) (eval r))]))

What kind of addition arity does this implment?