diff options
-rw-r--r-- | chickadee/graphics/seagull.scm | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm index 70ff46b..0df9b89 100644 --- a/chickadee/graphics/seagull.scm +++ b/chickadee/graphics/seagull.scm @@ -1194,9 +1194,16 @@ (map (lambda (exp) (simplify exp env)) exps)) (define (simplify:if predicate consequent alternate env) - `(if ,(simplify predicate env) - ,(simplify consequent env) - ,(simplify alternate env))) + (define predicate* (simplify predicate env)) + (cond + ((eq? predicate* #t) + (simplify consequent env)) + ((eq? predicate* #f) + (simplify alternate env)) + (else + `(if ,predicate* + ,(simplify consequent env) + ,(simplify alternate env))))) (define (simplify:lambda params body env) `(lambda ,params ,(simplify body env))) |