Last active
August 29, 2015 14:03
-
-
Save zeptometer/39fbfe489a61348346c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define (subst old new tree) | |
| (cond ((eq? old tree) new) | |
| ((pair? tree) | |
| (cons (subst old new (car tree)) | |
| (subst old new (cdr tree)))) | |
| (else tree))) | |
| (define-syntax x2y | |
| (ir-macro-transformer | |
| (lambda (form r compare) | |
| (let ((tree (cadr form))) | |
| `',(subst 'x 'y tree))))) | |
| ; (x2y (x x y (x ((x z)) z))) | |
| ; expect: (y y y (y ((y z)) z) | |
| ; => (x x y (x ((x z)) z)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment