Skip to content

Instantly share code, notes, and snippets.

@xieyuheng
Last active November 21, 2015 22:33
Show Gist options
  • Save xieyuheng/974cf5f16a93793644b9 to your computer and use it in GitHub Desktop.
Save xieyuheng/974cf5f16a93793644b9 to your computer and use it in GitHub Desktop.
(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