WHEN … EXCEPT
> (define-syntax when
(syntax-rules (except)
((_ condition form except c)
(if (and condition (not c))
(begin form)) )
((_ condition form ...)
(if condition (begin form ...)) )
) )
> (define n 18)
> (when (even? n)
(display 'not-prime) except (= n 2))
NOT-PRIME
> (set! n 2)
> (when (even? n)
(display 'not-prime) except (= n 2))
(nothing)
Note … must occur at the end of a list.
Previous slide
Next slide
Back to first slide
View graphic version