On Mon, Dec 22, 2014 at 12:52 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > `case` is like C's `switch` (but unlike similar constructs in other > C's switch does, however, allow the use of constant *expressions* as > case labels, so you can have something like `case FOO % 3`, where `FOO > % 3` can be computed at compile-time.
(define-syntax (case* stx) (syntax-case stx () [(_ what [v e ...] ...) (with-syntax ([(v* ...) (generate-temporaries #'(v ...))]) #'(let-syntax ([foo (λ(_) (with-syntax ([(v* ...) (list v ...)]) #'(case what [(v*) e ...] ...)))]) foo))])) (case* 3 [1 2] [(+ 1 2) 4]) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! ____________________ Racket Users list: http://lists.racket-lang.org/users