remix/remix/exp/cond.rkt
Jay McCarthy c8064354c7 notes
2014-12-11 09:57:27 -05:00

26 lines
588 B
Racket

#lang racket/base
(require (for-syntax racket/base
syntax/parse))
(define-syntax (brackets-cond stx)
(syntax-parse stx
[(_)
(syntax/loc stx
(error 'cond "Reach the end of cond"))]
[(_ ((~literal #%brackets) q . a) . more)
(syntax/loc stx
(if q (let () . a) (brackets-cond . more)))]
[(_ e . more)
(syntax/loc stx
(let () e (brackets-cond . more)))]))
(module+ test
(brackets-cond
(define x 5)
(#%brackets (even? x)
27)
(define y (+ x 6))
(#%brackets (odd? y)
28)
19))