April 01, 2004
Building Little Languages with Macros
(a)
(define-syntax rotate
(syntax-rules ()
((rotate a) (void)) ; i.e., do nothing
((rotate a b c ...) (begin
(swap a b)
(rotate b c ...)))))
(b)
(begin
(swap n e)
(rotate e s w))
(c)
(begin
(swap n e)
(begin
(swap e s)
(rotate s w)))
(d)
(begin
(swap n e)
(begin
(swap e s)
(begin
(swap s w)
(void))))
Example 4: rotate macro.
|
|
||||||||||||||||||||||||||||
|
|
|
|