Pattern Matching for Ports
(require port-match/base) | package: port-match |
pat must be a head pattern, which may be specified as follows:
(byte tail ...) —
matches a single byte. (bytes amt tail ...) —
matches a sequence of exactly amt bytes. (char tail ...) —
matches a single UTF-8 character. (string len tail ...) —
matches a sequence of exactly len characters. (regexp pattern tail ...) —
matches a sequence of characters or bytes which match pattern. The pattern must match immediately to count as a match (as if it began with ^). eof —
matches end-of-file. (seq head ...) —
matches each head in sequence.
Head patterns recognize one or more datums, which may be matched against tail patterns:
(app proc tail) —
calls proc with the matched datum, and matches the result against tail. (? proc tail ...) —
matches only if proc returns true when applied to the matched datum. id —
binds id to the matched datum.
Patterns may be combined as follows:
(and pat ...) —
matches only if every pat matches. (or pat ...) —
matches if at least one pat matches. _ —
matches anything.
1 Extending port-match
value
prop:port-match-expander : struct-type-property?
procedure
(port-match-expander? v) → boolean?
v : any/c