From 154824c9af56a887fb2cc6663346b0fe25edfda7 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 7 Jun 2013 14:31:46 -0400 Subject: [PATCH] Add match*? to unstable/match original commit: 12e5bc645bf6e4c8c74cd6460efefccbf5a5680d --- collects/unstable/match.rkt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/collects/unstable/match.rkt b/collects/unstable/match.rkt index 9fdd8d72..d40270f8 100644 --- a/collects/unstable/match.rkt +++ b/collects/unstable/match.rkt @@ -5,7 +5,7 @@ (for-syntax racket/base) (for-syntax syntax/parse)) -(provide match? as object) +(provide match? match*? as object) (define-syntax-rule (match? e p ...) (match e [p #t] ... [_ #f])) @@ -14,6 +14,14 @@ (syntax-rules () [(as ([x e] ...) p ...) (and (app (lambda (y) e) x) ... p ...)])) +;; Added by asumu +;; Like match? but with match* +(define-syntax (match*? stx) + (syntax-parse stx + [(_ (e ...) (p ...) ...) + (with-syntax ([(?_ ...) (generate-temporaries #'(e ...))]) + #'(match* (e ...) [(p ...) #t] ... [(?_ ...) #f]))])) + ;; Added by asumu ;; Match expander for objects from racket/class (define-match-expander object