...
Code Block |
---|
;; Given
(define-struct add (left right))
(define-struct sub (left right))
(define-struct mul (left right))
(define-struct div (left right))
;; an Arithmetic-Expression (AExp) is either:
;; - a number ;
;; - (make-add l r) where l,r are AExps;
;; - (make-sub l r) where l,r are AExps;
;; - (make-mul l r) where l,r are AExps; or
;; - (make-div l r) where l,r are AExps,
;; Remember that the define-struct function also automatically defines comparison functions:
;; add?, sub?, mul? and div?
;; Note: the function, number?, can be used to test if a value is a number.
|
Using this data definition, the arithmetic expression above corresponds to the structure ae1
defined by
...