Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To simplify the formulation of Scheme expressions as trees,
We'll require that we will limit each addition, subtraction, multiplication, and
division has operation to exactly two subexpressions. Of course, recursively,
each subexpression can be another addition, subtraction, multiplication,
or division. As a base case, an expression can also be a number.We will limit the
atomic elements of expressions to numbers.

Code Block

;; Given

(define-struct add (m n))
(define-struct sub (m n))
(define-struct mul (m n))
(define-struct div (m n))

; An ; an Arithmetic-Expression (AExp) is one of either:
;; - a number ;
;; - (make-add <var>m</var> <var>n</var>) ; where <var>m</var>,<var>n</var> are AExps;
;; - (make-sub <var>m</var> <var>n</var>) ; where <var>m</var>,<var>n</var> are AExps;
;; - (make-mul <var>m</var> <var>n</var>) ; where <var>m</var>,<var>n</var> are AExps; or
;; - (make-div <var>m</var> <var>n</var>) ; where <var>m</var>,<var>n</var> are AExps,

With this data definition, the above tree is modeled by the structure

...