[racket] a little macro exercise
8 minutes ago, Jay McCarthy wrote:
> Alright, here's the version with no mutation:
(cas-cad-e 1 [(1) (values 1 2 3)])
In other words:
(define-syntax-rule (cas-cad-e e [(n ...) code ...] ...)
(let/ec esc
(syntax-parameterize ([break (make-rename-transformer #'esc)])
(let*-values ([(tmp) e]
[(earlier? ret) (values #f (void))]
[(earlier? ret)
(if (or earlier? (equal? tmp n) ...)
(values #t (call-with-values (lambda () code ...) list))
(values earlier? ret))]
...)
(apply values ret)))))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!