Created
January 22, 2014 21:44
-
-
Save soegaard/8567959 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-syntax (myapply stx) | |
| (define (is-underscore? x) (equal? '_ (syntax->datum x))) | |
| (syntax-case stx () | |
| [(_ fun . args) | |
| (let* ([missing-ids (dar (filter is-underscore? (syntax->list #'args)))] | |
| [new-ids (dar (take (length missing-ids) (generate-temporaries #'args)))] | |
| [new-args (dar (replace-if is-underscore? (syntax->list #'args) new-ids))]) | |
| (with-syntax ([(new-arg ...) new-args] | |
| [(new-id ...) new-ids]) | |
| #'(lambda (new-id ...) (fun new-arg ...))))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment