FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Architecture & Design
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
April 01, 2004

Building Little Languages with Macros

(Page 8 of 12)
Apr04: Building Little Languages With Macros


(a)
(define-syntax rotate
   (syntax-rules ()
      ((rotate a c ...)
      (shift-to (c ... a) (a c ...)))))
(define-syntax shift-to
   (syntax-rules ()
      ((shift-to (from0 from ...) (to0 to ...))
      (let ((tmp from0))
         (set! to from) ...
         (set! to0 tmp))   )))

(b)
(shift-to (n e s w) (w n e s))

(c)
(let ((tmp n))
   (set! n e)
   (set! e s)
   (set! s w)
   (set! w n))

Example 5: New rotate macro.

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK