Last active
November 21, 2015 22:33
-
-
Save xieyuheng/974cf5f16a93793644b9 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
(require (for-syntax syntax/parse)) | |
(define-syntax fun | |
(lambda (stx) | |
(syntax-parse stx | |
#:literals (->) | |
[(fun [v ... -> r ...] ...) | |
(syntax | |
(match-lambda** [(v ...) (begin r ...)] ...))]))) | |
(check-expect | |
((fun | |
[1 x -> x x] | |
[_ _ -> 'fun 'fun]) | |
1 2) | |
2) | |
(define-syntax just-fun | |
(syntax-rules () | |
[(just-fun argument-list . body) | |
((fun . body) . argument-list)])) | |
(check-expect | |
(just-fun [1 2] | |
[1 x -> x x]) | |
2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment