<< Previous exercise (4.3) | Index | Next exercise (4.5) >>
(define (eval exp env) (cond ((...)) ((and? exp) (eval (and->if exp) env)) ((or? exp) (eval (or->if exp) env)) ((...)))) (define (and? exp) (tagged-list? exp 'and)) (define (and-operands exp) (cdr exp)) (define (and->if exp) (expand-and-operands (and-operands exp))) (define (expand-and-operands operands) (if (null? operands) 'true (make-if (car operands) (expand-and-operands (cdr operands)) 'false))) (define (or? exp) (tagged-list? exp 'or)) (define (or-operands exp) (cdr exp)) (define (or->if exp) (expand-or-operands (or-operands exp))) (define (expand-or-operands operands) (if (null? operands) 'false (make-if (car operands) 'true (expand-or-operands (cdr operands)))))
meteorgan