Created
October 4, 2013 16:33
-
-
Save jeapostrophe/6828783 to your computer and use it in GitHub Desktop.
This file contains 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
#lang racket/base | |
(require (for-syntax racket/base | |
racket/list) | |
rackunit) | |
(let () | |
(define-syntax (123-list stx) | |
(define middle-x-stx (second (syntax->list stx))) | |
(define x-id (syntax-e middle-x-stx)) | |
(define new-ctxt-stx (datum->syntax #f 'new-ctxt)) | |
(datum->syntax | |
new-ctxt-stx | |
(list (datum->syntax #'123-list 'let) | |
(list (list x-id | |
(datum->syntax #'123-list 3))) | |
(list (datum->syntax #'123-list '#%app) | |
(datum->syntax #'123-list 'list) | |
(datum->syntax #'123-list x-id) | |
middle-x-stx | |
x-id)))) | |
(define x 1) | |
(let ([x 2]) | |
(check-equal? (123-list x) (list 1 2 3))) | |
(define y 1) | |
(let ([y 2]) | |
(check-equal? (123-list y) (list 1 2 3)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment