commit e22aff53f3b287f006df54ef49172f24e7456deb parent 3eedd771b064347a1574fcbf0d7115a5a5aa3250 Author: AlexKnauth <alexander@knauth.org> Date: Mon, 20 Apr 2015 20:40:16 -0400 add kw-hash-lambda Diffstat:
| A | kw-utils/kw-hash-lambda.rkt | | | 29 | +++++++++++++++++++++++++++++ |
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/kw-utils/kw-hash-lambda.rkt b/kw-utils/kw-hash-lambda.rkt @@ -0,0 +1,29 @@ +#lang racket/base + +(provide kw-hash-lambda) + +(require "keyword-lambda.rkt" + "kw-hash.rkt" + (for-syntax racket/base + syntax/parse + )) +(module+ test + (require rackunit)) + +(define-syntax kw-hash-lambda + (lambda (stx) + (syntax-parse stx + [(kw-hash-lambda rest-args #:kws kw-hash:id body:expr ...+) + #'(keyword-lambda (kws kw-args . rest-args) + (let ([kw-hash (keyword-app-make-kw-hash kws kw-args)]) + body ...))]))) + +(module+ test + (test-case "kw-hash-lambda" + (define proc + (kw-hash-lambda rest-args #:kws kw-hash + (list rest-args kw-hash))) + (check-equal? (proc 0 1 2 #:a 'a #:b 'b) + (list '(0 1 2) (hash '#:a 'a '#:b 'b))) + (check-equal? (object-name proc) 'proc) + ))