remove 'case-lambdas'

pull/2/head
Matthew Butterick 10 years ago
parent 676f04cfc7
commit 763e54f6d2

@ -45,18 +45,14 @@
[else (error 'validate-txexpr (format "~v is not a list starting with a symbol" x))])) [else (error 'validate-txexpr (format "~v is not a list starting with a symbol" x))]))
(define/typed make-txexpr (define/typed (make-txexpr tag [attrs null] [elements null])
(case-> (Symbol -> Txexpr) (case-> (Symbol -> Txexpr)
(Symbol Txexpr-Attrs -> Txexpr) (Symbol Txexpr-Attrs -> Txexpr)
(Symbol Txexpr-Attrs (Listof Txexpr-Element) -> Txexpr)) (Symbol Txexpr-Attrs (Listof Txexpr-Element) -> Txexpr))
(case-lambda (define result (cons tag (append (if (empty? attrs) empty (list attrs)) elements)))
[(tag) (make-txexpr tag null null)] (if (txexpr? result)
[(tag attrs) (make-txexpr tag attrs null)] result
[(tag attrs elements) (error 'make-txexpr "This can't happen")))
(define result (cons tag (append (if (empty? attrs) empty (list attrs)) elements)))
(if (txexpr? result)
result
(error 'make-txexpr "This can't happen"))]))
(define/typed (txexpr->values x) (define/typed (txexpr->values x)
@ -212,13 +208,10 @@
;; function to split tag out of txexpr ;; function to split tag out of txexpr
(define deleted-signal (gensym)) (define deleted-signal (gensym))
(define/typed splitf-txexpr (define/typed (splitf-txexpr tx pred [proc (λ:([x : Xexpr]) deleted-signal)])
(case-> (Txexpr (Xexpr -> Boolean) -> (values Txexpr Txexpr-Elements)) (case-> (Txexpr (Xexpr -> Boolean) -> (values Txexpr Txexpr-Elements))
(Txexpr (Xexpr -> Boolean) (Xexpr -> Xexpr) -> (values Txexpr Txexpr-Elements))) (Txexpr (Xexpr -> Boolean) (Xexpr -> Xexpr) -> (values Txexpr Txexpr-Elements)))
(case-lambda (define: matches : Txexpr-Elements null)
[(tx pred) (splitf-txexpr tx pred (λ:([x : Xexpr]) deleted-signal))]
[(tx pred proc)
(define: matches : Txexpr-Elements null)
(define/typed (do-extraction x) (define/typed (do-extraction x)
(Xexpr -> Xexpr) (Xexpr -> Xexpr)
(cond (cond
@ -231,7 +224,7 @@
(define: tx-extracted : Xexpr (do-extraction tx)) ;; do this first to fill matches (define: tx-extracted : Xexpr (do-extraction tx)) ;; do this first to fill matches
(values (if (txexpr? tx-extracted) (values (if (txexpr? tx-extracted)
tx-extracted tx-extracted
(error 'splitf-txexpr "Can't get here")) (reverse matches))])) (error 'splitf-txexpr "Can't get here")) (reverse matches)))
(define/typed (xexpr->html x) (define/typed (xexpr->html x)

Loading…
Cancel
Save