From 45127853db7cf600a4947b72483f73826e27ceab Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 30 May 2006 17:47:51 +0000 Subject: [PATCH] improve regexp-case code svn: r3125 --- collects/swindle/misc.ss | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/collects/swindle/misc.ss b/collects/swindle/misc.ss index 000d69998f..7f10ee4c88 100644 --- a/collects/swindle/misc.ss +++ b/collects/swindle/misc.ss @@ -1853,7 +1853,7 @@ ;;> Try to match the given `string' against several regexps. Each clause ;;> has one of the following forms: ;;> * (re => function): if `string' matches `re', apply `function' on the -;;> result list. +;;> resulting list. ;;> * ((re args ...) body ...): if `string' matches `re', bind the tail of ;;> results (i.e, excluding the whole match result) to the given ;;> arguments and evaluate the body. The whole match result (the first @@ -1874,12 +1874,9 @@ body ...) r)))] [(re body ...) #'((regexp-match re s) body ...)])) - (define (do-clauses c) - (cond [(null? c) c] - [(pair? c) (cons (do-clause (car c)) (do-clauses (cdr c)))] - [(syntax? c) (do-clauses (syntax-e c))])) (syntax-case stx () [(_ str clause ...) - #`(let ([s str]) (cond #,@(do-clauses #'(clause ...))))])) + #`(let ([s str]) + (cond #,@(map do-clause (syntax->list #'(clause ...)))))])) )