6 Pattern Matching
(require (planet cce/scheme:7:4/match)) |
This module provides tools for pattern matching with match.
(match? val-expr pat ...) |
Returns #t if the result of val-expr matches any of
pat, and returns #f otherwise.
Examples: | |||||||||||||||
|
(define-struct-pattern pat-id struct-id) |
Defines pat-id as a match expander that takes one pattern argument per
field of the structure described by struct-id. The resulting match
expander recognizes instances of the structure and matches their fields against
the corresponding patterns.
Examples: | ||||||||
|
(as ([lhs-id rhs-expr] ...) pat ...) |
As a match expander, binds each lhs-id as a pattern variable with the
result value of rhs-expr, and continues matching each subsequent
pat.
Example: | ||||
|
As an expression, constructs an instance of the structure described by
struct-id with fields specified by each expr.
As a match expander, matches instances of the structure described by struct-id with fields matched by each pat.
Examples: | |||||||||
|