[racket] a little macro exercise

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sat Oct 9 00:39:30 EDT 2010

You got me

Sent from my iPhone

On Oct 8, 2010, at 10:33 PM, Eli Barzilay <eli at barzilay.org> wrote:

> 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!


Posted on the users mailing list.