Add regexp-filter to unstable/string.

This commit is contained in:
Vincent St-Amour 2011-11-30 17:54:15 -05:00
parent 29bea4863e
commit c720d0f6f7
2 changed files with 20 additions and 0 deletions

View File

@ -27,3 +27,12 @@
string?]{
@racket[write]s @racket[v] to a string and returns it.
}
@addition{Vincent St-Amour}
@defproc[(regexp-filter [pattern (or/c string? bytes? regexp? byte-regexp?)]
[lst (listof (or/c string? bytes? path? input-port?))])
(listof (or/c string? bytes? path? input-port?))]{
Keeps only the elements of @racket[lst] that match @racket[pattern].
}

View File

@ -33,3 +33,14 @@
[lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)]
[read/string (string? . -> . serializable?)]
[write/string (serializable? . -> . string?)])
;; added by stamourv
(define (regexp-filter r log)
(for/list ([l (in-list log)] #:when (regexp-match r l))
l))
(provide/contract
[regexp-filter ((or/c string? bytes? regexp? byte-regexp?)
(listof (or/c string? bytes? path? input-port?))
. -> . (listof (or/c string? bytes? path? input-port?)))])