[racket] a little macro exercise

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Fri Oct 8 22:42:34 EDT 2010

> Note that it was unclear to me where the "break" form could appear,
> so I restricted it to being at the end of the clause, like how
> people typically use "break" in C-like "switch" forms.

"it was unclear ... so I restricted" = the refuge of rogues.

Here's a test that my version passes:

(define (cas3 v)
  (let ([w true])
    (cas-cad-e v
               [(0) (set! w false)]
               [(1) (if w (break 1) (break 0))])))

(check-expect (cas3 0) 0)
(check-expect (cas3 1) 1)

Shriram


Posted on the users mailing list.