Schemer
Schemer

Reputation: 1665

Scheme: define-syntax-rule pattern matching syntax

I would like to rewrite this:

(define-syntax match-rewriter
  (syntax-rules ()
    ((_ (patt body) ...)
      (λ (x) (match x (patt body) ... (_ x))))))

using (define-syntax-rule pattern template) but I can't seem to get the syntax right. Any advice is appreciated.

Thanks.

Upvotes: 1

Views: 342

Answers (1)

Jeremiah Willcock
Jeremiah Willcock

Reputation: 30969

Try:

(define-syntax-rule (match-rewriter (patt body) ...)
  (lambda (x) (match x (patt body) ... (_ x))))

Upvotes: 1

Related Questions