Practice 4.5
只改变cond-actions
(define (cond-actions clause)
(if (eq? (cadr caluse) '=>)
(list (sequence->exp (cddr clause)) (cond-predicate clause))
(cdr clause)))
其他不变
(define (expand-clauses clauses)
(if (null? clauses)
'false
(let ((first (car clauses))
(rest (cdr clauses)))
(if (cond-else-clause? first)
(if (null? rest)
(sequence->exp (cond-actions first))
(error "ELSE clause isn't last --- COND->IF"
clauses))
(make-if (cond-predicate first)
(sequence->exp (cond-actions first))
(expand-clauses rest))))))
(define (cond-predicate clause) (car clause))