[plt-scheme] alternative amb macro

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sun Nov 26 12:23:07 EST 2006

michael rice skrev:
> Can this be accomplished with a single (simpler)
> macro?
> 
> (define-syntax my-amb-aux
>   (syntax-rules ()
>     ((_ (quote (c1 ...)))
>      (amb c1 ...))))
> 
> (define-syntax my-amb
>   (syntax-rules ()
>     ((_ choices)
>      (my-amb-aux choices))))
> 
> Welcome to DrScheme, version 360.
> Language: Swindle.
>> (my-amb '(1 2 3))
> 1
>> (amb)
> 2
>> (amb)
> 3

Maybe this?

(define-syntax my-amb
   (syntax-rules (quote)
     [(_ (quote (c1 ...)))
      (amb c1 ...)]))

(my-amb '(1 2 3))
(amb)
(amb)
(amb)

-- 
Jens Axel Søgaard



Posted on the users mailing list.