Add regexp-filter to unstable/string.
This commit is contained in:
parent
29bea4863e
commit
c720d0f6f7
|
@ -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].
|
||||
}
|
||||
|
|
|
@ -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?)))])
|
||||
|
|
Loading…
Reference in New Issue
Block a user