diff --git a/txexpr/base.rkt b/txexpr/base.rkt index cd1eced..80ed2a8 100644 --- a/txexpr/base.rkt +++ b/txexpr/base.rkt @@ -261,8 +261,7 @@ x)))) ;; function to split tag out of txexpr -(define deleted-signal (gensym)) -(define+provide+safe (splitf-txexpr tx pred [proc (λ (x) deleted-signal)]) +(define+provide+safe (splitf-txexpr tx pred [proc (λ (x) #f)]) ((txexpr? procedure?) (procedure?) . ->* . (values txexpr? txexpr-elements?)) (unless (txexpr? tx) (raise-argument-error 'splitf-txexpr "txexpr?" tx)) @@ -273,8 +272,7 @@ (set! matches (cons x matches)) (proc x)] [(? txexpr?) (let-values ([(tag attrs elements) (txexpr->values x)]) - (txexpr-unsafe tag attrs (filter-not (λ (e) (eq? e deleted-signal)) - (map extract! elements))))] + (txexpr-unsafe tag attrs (filter values (map extract! elements))))] [_ x])) (define tx-extracted (extract! tx)) ;; do this first to fill matches (values tx-extracted (reverse matches))) diff --git a/txexpr/scribblings/txexpr.scrbl b/txexpr/scribblings/txexpr.scrbl index 17e0f74..5a1f62c 100644 --- a/txexpr/scribblings/txexpr.scrbl +++ b/txexpr/scribblings/txexpr.scrbl @@ -473,7 +473,7 @@ In practice, most @racket[_txexpr-element]s are strings. But it's unwise to pass (splitf-txexpr [tx txexpr?] [pred procedure?] -[replace-proc procedure? (λ (x) null)]) +[replace-proc procedure? (λ (x) #f)]) (values txexpr? (listof txexpr-element?))] Recursively descend through @racket[_txexpr] and extract all elements that match @racket[_pred]. Returns two values: a @racket[_txexpr] with the matching elements removed, and the list of matching elements. Sort of esoteric, but I've needed it more than once, so here it is.