5.14 match

► |  | How to Design Programs Languages

1 | Beginning Student
2 | Beginning Student with List Abbreviations
3 | Intermediate Student
4 | Intermediate Student with Lambda
5 | Advanced Student
| Index

▼ | 5 | Advanced Student

5.1 | define
5.2 | define-struct
5.3 | define-datatype
5.4 | lambda
5.5 | Function Calls
5.6 | begin
5.7 | begin0
5.8 | set!
5.9 | delay
5.10 | shared
5.11 | let
5.12 | recur
5.13 | case
5.14 | match
5.15 | when and unless
5.16 | Primitive Operations
5.17 | Unchanged Forms

On this page:

match

top← prev up next →

#### 5.14`` match

( match expr [pattern expr] ...)

A match form contains one or more “lines” that are surrounded by parentheses or square brackets. Each line contains a pattern – a description of a value – and an answer expr. The initial expr is evaluated, and the resulting value is matched against the pattern in each line, where the lines are considered in order. The first line that contains a matching pattern provides an answer expr whose value is the result of the whole match expression. This expr may reference identifiers bound in the matching pattern. If none of the lines contains a matching pattern, it is an error.
top← prev up next →