previous | index | next

Arithmetic Expressions Revisited

Recall from chapter 8:
     (* (+ 3 4) (- 9 (* 2 3))) ⇒ 21 - PREFIX form

     (evaluate '((3 + 4) * (9 - (2 * 3)))) ⇒ 21 - INFIX form
evaluate worked by processing the expressions as an expression tree:

However,

     (evaluate '((3 + 4) * 9 - 2 * 3))
will cause not work because evaluate expects all expressions to be fully parenthesized 3-element lists.

But ((3 + 4) * 9 - 2 * 3) is mathematically legal.


previous | index | next