diff --git a/collects/syntax/scribblings/stx.scrbl b/collects/syntax/scribblings/stx.scrbl index 84f759a85e..a016c45b5a 100644 --- a/collects/syntax/scribblings/stx.scrbl +++ b/collects/syntax/scribblings/stx.scrbl @@ -37,6 +37,13 @@ Takes the car of a @techlink[#:doc refman]{syntax pair}.} Takes the cdr of a @techlink[#:doc refman]{syntax pair}.} +@defproc[(stx-map [proc procedure?] + [stxl stx-list?] ...) + list?]{ + +Equivalent to @racket[(map proc (stx->list stxl) ...)]. +} + @defproc[(module-or-top-identifier=? [a-id identifier?] [b-id identifier?]) boolean?]{ diff --git a/collects/syntax/stx.rkt b/collects/syntax/stx.rkt index d57371eee3..5be16d2122 100644 --- a/collects/syntax/stx.rkt +++ b/collects/syntax/stx.rkt @@ -7,6 +7,7 @@ (provide stx-null? stx-pair? stx-list? stx-car stx-cdr stx->list + stx-map module-or-top-identifier=?) ;; a syntax null? @@ -70,6 +71,13 @@ #f)))) e)))) +(define (stx-map f . stxls) + (for ([stxl (in-list stxls)] + [i (in-naturals)]) + (unless (stx-list? stxl) + (apply raise-type-error 'stx-map "stx-list" i stxls))) + (apply map f (map stx->list stxls))) + (define (module-or-top-identifier=? a b) (or (free-identifier=? a b) (and (eq? (syntax-e a) (syntax-e b))