beautiful-racket/beautiful-racket-lib/br/private/syntax-flatten.rkt
Matthew Butterick f02e605a9c refactory
2016-08-14 23:01:19 -04:00

12 lines
329 B
Racket

#lang racket/base
(require racket/list)
(provide (all-defined-out))
(define (syntax-flatten stx)
(flatten
(let loop ([stx stx])
(let* ([stx-unwrapped (syntax-e stx)]
[maybe-pair (and (pair? stx-unwrapped) (flatten stx-unwrapped))])
(if maybe-pair
(map loop maybe-pair)
stx)))))