/usr/share/doc/racket/reference/match.html is in racket-doc 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>9 Pattern Matching</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="icons.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2 </td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3 </td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4 </td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5 </td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6 </td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7 </td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8 </td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10 </td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11 </td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12 </td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13 </td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15 </td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16 </td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17 </td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18 </td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">►</a></td><td>9 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Pattern Matching</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">9.1 </td><td><a href="#%28part._.Additional_.Matching_.Forms%29" class="tocviewlink" data-pltdoc="x">Additional Matching Forms</a></td></tr><tr><td align="right">9.2 </td><td><a href="#%28part._.Extending_match%29" class="tocviewlink" data-pltdoc="x">Extending <span class="RktSym"><span class="RktStxLink">match</span></span></a></td></tr><tr><td align="right">9.3 </td><td><a href="#%28part._.Library_.Extensions%29" class="tocviewlink" data-pltdoc="x">Library Extensions</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match</span></span></a></td></tr><tr><td><span class="tocsublinknumber">9.1<tt> </tt></span><a href="#%28part._.Additional_.Matching_.Forms%29" class="tocsubseclink" data-pltdoc="x">Additional Matching Forms</a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match*</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2Fvalues%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match/<span class="mywbr"> </span>values</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define/<span class="mywbr"> </span>match</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>lambda</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%2A%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>lambda*</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%2A%2A%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>lambda**</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>let</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%2A%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>let*</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let-values%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>let-<wbr></wbr>values</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%2A-values%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>let*-<wbr></wbr>values</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-letrec%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>letrec</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>define</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define-values%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match-<wbr></wbr>define-<wbr></wbr>values</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._exn~3amisc~3amatch~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">exn:<span class="mywbr"> </span>misc:<span class="mywbr"> </span>match?</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._failure-cont%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">failure-<wbr></wbr>cont</span></span></a></td></tr><tr><td><span class="tocsublinknumber">9.2<tt> </tt></span><a href="#%28part._.Extending_match%29" class="tocsubseclink" data-pltdoc="x">Extending <span class="RktSym"><span class="RktStxLink">match</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define-<wbr></wbr>match-<wbr></wbr>expander</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._prop~3amatch-expander%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prop:<span class="mywbr"> </span>match-<wbr></wbr>expander</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._prop~3alegacy-match-expander%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prop:<span class="mywbr"> </span>legacy-<wbr></wbr>match-<wbr></wbr>expander</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._match-expander~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">match-<wbr></wbr>expander?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._legacy-match-expander~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">legacy-<wbr></wbr>match-<wbr></wbr>expander?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._match-equality-test%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">match-<wbr></wbr>equality-<wbr></wbr>test</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2Fderived%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match/<span class="mywbr"> </span>derived</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%2Fderived%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">match*/<span class="mywbr"> </span>derived</span></span></a></td></tr><tr><td><span class="tocsublinknumber">9.3<tt> </tt></span><a href="#%28part._.Library_.Extensions%29" class="tocsubseclink" data-pltdoc="x">Library Extensions</a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">==</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._struct%2A%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">struct*</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="Random_generation.html" title="backward to "8.11 Random generation"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "The Racket Reference"" data-pltdoc="x">up</a> <a href="control.html" title="forward to "10 Control Flow"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-part-tag=""match"">9<tt> </tt><a name="(part._match)"></a><a name="(mod-path._racket/match)"></a>Pattern Matching</h3><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="finger.png" alt="+" width="24" height="24"/></span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&rel=match.html&version=6.1" class="Sq" data-pltdoc="x">Pattern Matching</a> in <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&rel=index.html&version=6.1" class="Sq" data-pltdoc="x"><span style="font-weight: bold">The Racket Guide</span></a> introduces pattern matching.</p></blockquote></blockquote></blockquote><p>The <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> form and related forms support general pattern
matching on Racket values. See also <a href="regexp.html" data-pltdoc="x">Regular Expressions</a> for information
on regular-expression matching on strings, bytes, and streams.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/match</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">base</span></span></td></tr></table></div><div class="SIntrapara">The bindings documented in this section are provided by the <a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/match</span></a> and <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket</span></a> libraries, but not <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/base</span></a>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match</a></span></span><span class="hspace"> </span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktVar">clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">clause</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">=></span><span class="hspace"> </span><span class="RktVar">id</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktPn">#:when</span><span class="hspace"> </span><span class="RktVar">cond-expr</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Finds the first <span class="RktVar">pat</span> that matches the result of
<span class="RktVar">val-expr</span>, and evaluates the corresponding <span class="RktVar">body</span>s with
bindings introduced by <span class="RktVar">pat</span> (if any). The last <span class="RktVar">body</span>
in the matching clause is evaluated in tail position with respect to
the <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> expression.</div></p><p>To find a match, the <span class="RktVar">clause</span>s are tried in order. If no
<span class="RktVar">clause</span> matches, then the <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._exn~3amisc~3amatch~3f%29%29" class="RktValLink" data-pltdoc="x">exn:misc:match?</a></span> exception is raised.</p><p>An optional <span class="RktPn">#:when</span><span class="stt"> </span><span class="RktVar">cond-expr</span> specifies that the pattern
should only match if <span class="RktVar">cond-expr</span> produces a true value.
<span class="RktVar">cond-expr</span> is in the scope of all of the variables bound in
<span class="RktVar">pat</span>. <span class="RktVar">cond-expr</span> must not mutate the object being
matched before calling the failure procedure, otherwise the behavior
of matching is unpredictable. See also <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._failure-cont%29%29" class="RktStxLink" data-pltdoc="x">failure-cont</a></span>, which is
a lower-level mechanism achieving the same ends.</p><p>An optional <span class="RktPn">(</span><span class="RktVar">=></span><span class="stt"> </span><span class="RktVar">id</span><span class="RktPn">)</span> between a <span class="RktVar">pat</span> and the
<span class="RktVar">body</span>s is bound to a <span style="font-style: italic">failure procedure</span> of zero
arguments. If this procedure is invoked, it escapes back to the
pattern matching expression, and resumes the matching process as if
the pattern had failed to match. The <span class="RktVar">body</span>s must not mutate
the object being matched before calling the failure procedure,
otherwise the behavior of matching is unpredictable.</p><p>The grammar of <span class="RktVar">pat</span> is as follows, where non-italicized
identifiers are recognized symbolically (i.e., not by binding).</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktVar">pat</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">::=</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">id</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match anything, bind identifier</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">var</span><span class="stt"> </span><span class="RktVar">id</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match anything, bind identifier</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">_</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match anything</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">literal</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match literal</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">quote</span><span class="stt"> </span><span class="RktVar">datum</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> value</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">list</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match sequence of <span class="RktVar">lvp</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">list-rest</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktSym">...</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">lvp</span>s consed onto a <span class="RktVar">pat</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">list-no-order</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">pat</span>s in any order</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">list-no-order</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">pat</span>s in any order</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">vector</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match vector of <span class="RktVar">pat</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">hash-table</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match hash table</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">hash-table</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktSym">...+</span><span class="stt"> </span><span class="RktVar">ooo</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match hash table</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">cons</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match pair of <span class="RktVar">pat</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">mcons</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match mutable pair of <span class="RktVar">pat</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">box</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match boxed <span class="RktVar">pat</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktVar">struct-id</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">struct-id</span> instance</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">struct</span><span class="stt"> </span><span class="RktVar">struct-id</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">struct-id</span> instance</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">regexp</span><span class="stt"> </span><span class="RktVar">rx-expr</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match string</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">regexp</span><span class="stt"> </span><span class="RktVar">rx-expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match string, result with <span class="RktVar">pat</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">pregexp</span><span class="stt"> </span><span class="RktVar">px-expr</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match string</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">pregexp</span><span class="stt"> </span><span class="RktVar">px-expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match string, result with <span class="RktVar">pat</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">and</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match when all <span class="RktVar">pat</span>s match</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">or</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match when any <span class="RktVar">pat</span> match</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">not</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match when no <span class="RktVar">pat</span> matches</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">app</span><span class="stt"> </span><span class="RktVar">expr</span><span class="stt"> </span><span class="RktSym">pats</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktPn">(</span><span class="RktVar">expr</span> value<span class="RktPn">)</span> output values to <span class="RktVar">pat</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">?</span><span class="stt"> </span><span class="RktVar">expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match if <span class="RktPn">(</span><span class="RktVar">expr</span> value<span class="RktPn">)</span> and <span class="RktVar">pat</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktSym">quasiquote</span><span class="stt"> </span><span class="RktVar">qp</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match a quasipattern</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">derived-pattern</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match using extension</p></td></tr><tr><td><p><span class="RktVar">literal</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">::=</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVal">#t</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match true</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVal">#f</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match false</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">string</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> string</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">bytes</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> byte string</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">number</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> number</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">char</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> character</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">keyword</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> keyword</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">regexp</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> regexp literal</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">pregexp</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> pregexp literal</p></td></tr><tr><td><p><span class="RktVar">lvp</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">::=</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">ooo</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>greedily match <span class="RktVar">pat</span> instances</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">pat</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">pat</span></p></td></tr><tr><td><p><span class="RktVar">qp</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">::=</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">literal</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match literal</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">id</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match symbol</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktVar">qp</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match sequences of <span class="RktVar">qp</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktVar">qp</span><span class="stt"> </span><span class="RktSym">...</span><span class="stt"> </span><span class="RktPn">. </span><span class="RktVar">qp</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">qp</span>s ending <span class="RktVar">qp</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktPn">(</span><span class="RktVar">qp</span><span class="stt"> </span><span class="RktVar">ooo</span><span class="stt"> </span><span class="RktPn">. </span><span class="RktVar">qp</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">qp</span>s beginning with repeated <span class="RktVar">qp</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVar">qp</span><span class="stt"> </span><span class="RktVal">...</span><span class="RktVal">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match vector of <span class="RktVar">qp</span>s</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVal">#&</span><span class="RktVar">qp</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match boxed <span class="RktVar">qp</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktRdr">,</span><span class="RktVar">pat</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">pat</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktRdr">,@</span><span class="RktPn">(</span><span class="RktSym">list</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktSym">...</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">lvp</span>s, spliced</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktRdr">,@</span><span class="RktPn">(</span><span class="RktSym">list-rest</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktSym">...</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match <span class="RktVar">lvp</span>s plus <span class="RktVar">pat</span>, spliced</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktRdr">,@</span><span class="RktVal">'</span><span class="RktVar">qp</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>match list-matching <span class="RktVar">qp</span>, spliced</p></td></tr><tr><td><p><span class="RktVar">ooo</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">::=</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">...</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>zero or more; <span class="RktSym">...</span> is literal</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">___</span></p></td><td><p><span class="hspace"> </span></p></td><td><p>zero or more</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">..</span><span class="RktVar">k</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">k</span> or more</p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span><span class="stt">| </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktSym">__</span><span class="RktVar">k</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="RktVar">k</span> or more</p></td></tr></table></p><p>In more detail, patterns match as follows:</p><ul><li><p><span class="RktVar">id</span> (excluding the reserved names <span class="RktSym">_</span>,
<span class="RktSym">...</span>, <span class="RktSym">.._</span>,
<span class="RktSym">..</span><span class="RktVar">k</span>, and
<span class="RktSym">..</span><span class="RktVar">k</span> for non-negative integers
<span class="RktVar">k</span>) or <span class="RktPn">(</span><span class="RktSym">var</span><span class="stt"> </span><span class="RktVar">id</span><span class="RktPn">)</span> —<wbr></wbr> matches anything, and binds <span class="RktVar">id</span> to the
matching values. If an <span class="RktVar">id</span> is used multiple times
within a pattern, the corresponding matches must be the same
according to <span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._match-equality-test%29%29" class="RktValLink" data-pltdoc="x">match-equality-test</a></span><span class="RktPn">)</span>, except that
instances of an <span class="RktVar">id</span> in different <span class="RktSym">or</span> and
<span class="RktSym">not</span> sub-patterns are independent.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(3 2 1)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">x</span><span class="hspace"> </span><span class="RktVal">y</span><span class="hspace"> </span><span class="RktVal">z</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(1 (x y z))</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktSym">_</span> —<wbr></wbr> matches anything, without binding any
identifiers.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktVal">#t</span>, <span class="RktVal">#f</span>, <span class="RktVar">string</span>, <span class="RktVar">bytes</span>,
<span class="RktVar">number</span>, <span class="RktVar">char</span>, or <span class="RktPn">(</span><span class="RktSym">quote</span><span class="stt"> </span><span class="RktVar">datum</span><span class="RktPn">)</span> —<wbr></wbr> matches an <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span> constant.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">"yes"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVal">"no"</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVal">"yes"</span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">list</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> matches a list
of elements. In the case of <span class="RktPn">(</span><span class="RktSym">list</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span>, the pattern matches a list with as many element as
<span class="RktVar">pat</span>s, and each element must match the corresponding
<span class="RktVar">pat</span>. In the more general case, each <span class="RktVar">lvp</span>
corresponds to a “spliced” list of greedy matches.</p><p>For spliced lists, <span class="RktSym">...</span> and <span class="RktSym">___</span>
are aliases for zero or more matches. The
<span class="RktSym">..</span><span class="RktVar">k</span> and <span class="RktSym">__</span><span class="RktVar">k</span>
forms are also aliases, specifying <span class="RktVar">k</span> or more
matches. Pattern variables that precede these splicing
operators are bound to lists of matching forms.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(3 2 1)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 3)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">..3</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">else</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'else</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">..3</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">else</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 3 4)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">..3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">else</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 3 4)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">..3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">else</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 2 2)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">list-rest</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span> —<wbr></wbr>
similar to a <span class="RktSym">list</span> pattern, but the final
<span class="RktVar">pat</span> matches the “rest” of the list after the last
<span class="RktVar">lvp</span>. In fact, the matched value can be a non-list
chain of pairs (i.e., an “improper list”) if <span class="RktVar">pat</span>
matches non-list values.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">4</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">list-rest</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktSym">d</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">d</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">4</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">4</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">list-rest</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktSym">d</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">d</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((1 2 3) 4)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">list-no-order</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr>
similar to a <span class="RktSym">list</span> pattern, but the elements to
match each <span class="RktVar">pat</span> can appear in the list in any order.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">list-no-order</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">list-no-order</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="stt"> </span><span class="RktVar">lvp</span><span class="RktPn">)</span> —<wbr></wbr>
generalizes <span class="RktSym">list-no-order</span> to allow a pattern
that matches multiple list elements that are interspersed in
any order with matches for the other patterns.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">6</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">list-no-order</span><span class="hspace"> </span><span class="RktVal">6</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(1 3 4 5)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">vector</span><span class="stt"> </span><span class="RktVar">lvp</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> like a
<span class="RktSym">list</span> pattern, but matching a vector.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29" class="RktValLink" data-pltdoc="x">vector</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">..3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 2 2)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">hash-table</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr>
similar to <span class="RktSym">list-no-order</span>, but matching against
hash table’s key–value pairs.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">#hash</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">"a"</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">"b"</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">hash-table</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVal">"b"</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVal">"a"</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 1)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">hash-table</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktMeta">...+</span><span class="stt"> </span><span class="RktVar">ooo</span><span class="RktPn">)</span>
—<wbr></wbr> Generalizes <span class="RktSym">hash-table</span> to support a final
repeating pattern.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">#hash</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">"a"</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">"b"</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">hash-table</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">key</span><span class="hspace"> </span><span class="RktSym">val</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">key</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'("a" "b")</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">cons</span><span class="stt"> </span><span class="RktVar">pat1</span><span class="stt"> </span><span class="RktVar">pat2</span><span class="RktPn">)</span> —<wbr></wbr> matches a pair value.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">mcons</span><span class="stt"> </span><span class="RktVar">pat1</span><span class="stt"> </span><span class="RktVar">pat2</span><span class="RktPn">)</span> —<wbr></wbr> matches a mutable pair value.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="mpairs.html#%28def._%28%28quote._~23~25kernel%29._mcons%29%29" class="RktValLink" data-pltdoc="x">mcons</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">immutable</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="mpairs.html#%28def._%28%28quote._~23~25kernel%29._mcons%29%29" class="RktValLink" data-pltdoc="x">mcons</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">mutable</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'mutable</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">box</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span> —<wbr></wbr> matches a boxed value.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">#&</span><span class="RktVal">1</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="boxes.html#%28def._%28%28quote._~23~25kernel%29._box%29%29" class="RktValLink" data-pltdoc="x">box</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktVar">struct-id</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> or
<span class="RktPn">(</span><span class="RktSym">struct</span><span class="stt"> </span><span class="RktVar">struct-id</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="RktPn">)</span> —<wbr></wbr>
matches an instance of a structure type named
<span class="RktVar">struct-id</span>, where each field in the instance matches
the corresponding <span class="RktVar">pat</span>. See also <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._struct%2A%29%29" class="RktStxLink" data-pltdoc="x">struct*</a></span>.</p><p>Usually, <span class="RktVar">struct-id</span> is defined with
<span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>. More generally, <span class="RktVar">struct-id</span>
must be bound to expansion-time information for a structure
type (see <a href="structinfo.html" data-pltdoc="x">Structure Type Transformer Binding</a>), where the information
includes at least a predicate binding and field accessor
bindings corresponding to the number of field
<span class="RktVar">pat</span>s. In particular, a module import or a
<span class="RktSym"><a href="creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._unit%29%29" class="RktStxLink" data-pltdoc="x">unit</a></span> import with a signature containing a
<span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> declaration can provide the structure type
information.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span><span class="hspace"> </span><span class="RktSym">tree</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">val</span><span class="hspace"> </span><span class="RktSym">left</span><span class="hspace"> </span><span class="RktSym">right</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-tree</span><span class="hspace"> </span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-tree</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">tree</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">tree</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(0 1)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">struct</span><span class="stt"> </span><span class="RktVar">struct-id</span><span class="stt"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="RktPn">)</span> —<wbr></wbr>
matches any instance of <span class="RktVar">struct-id</span>, without regard to
contents of the fields of the instance.</p></li><li><p><span class="RktPn">(</span><span class="RktSym">regexp</span><span class="stt"> </span><span class="RktVar">rx-expr</span><span class="RktPn">)</span> —<wbr></wbr> matches a
string that matches the regexp pattern produced by
<span class="RktVar">rx-expr</span>; see <a href="regexp.html" data-pltdoc="x">Regular Expressions</a> for more information
about regexps.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">"apple"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29" class="RktValLink" data-pltdoc="x">regexp</a></span><span class="hspace"> </span><span class="RktVal">#rx"p+"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">"banana"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29" class="RktValLink" data-pltdoc="x">regexp</a></span><span class="hspace"> </span><span class="RktVal">#rx"p+"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'no</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">regexp</span><span class="stt"> </span><span class="RktVar">rx-expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span> —<wbr></wbr> extends
the <span class="RktSym">regexp</span> form to further constrain the match
where the result of <span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp-match%29%29" class="RktValLink" data-pltdoc="x">regexp-match</a></span> is matched against
<span class="RktVar">pat</span>.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">"apple"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29" class="RktValLink" data-pltdoc="x">regexp</a></span><span class="hspace"> </span><span class="RktVal">#rx"p+(.)"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">"l"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">"append"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29" class="RktValLink" data-pltdoc="x">regexp</a></span><span class="hspace"> </span><span class="RktVal">#rx"p+(.)"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">"l"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'no</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">pregexp</span><span class="stt"> </span><span class="RktVar">rx-expr</span><span class="RktPn">)</span> or
<span class="RktPn">(</span><span class="RktSym">regexp</span><span class="stt"> </span><span class="RktVar">rx-expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span> —<wbr></wbr> like the
<span class="RktSym">regexp</span> patterns, but if <span class="RktVar">rx-expr</span>
produces a string, it is converted to a pattern using
<span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._pregexp%29%29" class="RktValLink" data-pltdoc="x">pregexp</a></span> instead of <span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29" class="RktValLink" data-pltdoc="x">regexp</a></span>.</p></li><li><p><span class="RktPn">(</span><span class="RktSym">and</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> matches if all
of the <span class="RktVar">pat</span>s match. This pattern is often used as
<span class="RktPn">(</span><span class="RktSym">and</span><span class="stt"> </span><span class="RktVar">id</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span> to bind <span class="RktVar">id</span>
to the entire value that matches <span class="RktVar">pat</span>.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 3)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">or</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> matches if any of
the <span class="RktVar">pat</span>s match. <span style="font-weight: bold">Beware</span>: the result expression
can be duplicated once for each <span class="RktVar">pat</span>! Identifiers in
<span class="RktVar">pat</span> are bound only in the corresponding copy of the
result expression; in a module context, if the result
expression refers to a binding, then all <span class="RktVar">pat</span>s
must include the binding.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">not</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> matches when
none of the <span class="RktVar">pat</span>s match, and binds no identifiers.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'no</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">app</span><span class="stt"> </span><span class="RktVar">expr</span><span class="stt"> </span><span class="RktVar">pats</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> applies
<span class="RktVar">expr</span> to the value to be matched; the result of the
application is matched against <span class="RktVar">pats</span>.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">app</span><span class="hspace"> </span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._length%29%29" class="RktValLink" data-pltdoc="x">length</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">app</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._split-at%29%29" class="RktValLink" data-pltdoc="x">split-at</a></span><span class="hspace"> </span><span class="RktSym">v</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">?</span><span class="stt"> </span><span class="RktVar">expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> —<wbr></wbr> applies
<span class="RktVar">expr</span> to the value to be matched, and checks whether
the result is a true value; the additional <span class="RktVar">pat</span>s must
also match; i.e., <span class="RktSym">?</span> combines a predicate
application and an <span class="RktSym">and</span> pattern. However,
<span class="RktSym">?</span>, unlike <span class="RktSym">and</span>, guarantees that
<span class="RktVar">expr</span> is matched before any of the <span class="RktVar">pat</span>s.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._odd~3f%29%29" class="RktValLink" data-pltdoc="x">odd?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktPn">(</span><span class="RktSym">quasiquote</span><span class="stt"> </span><span class="RktVar">qp</span><span class="RktPn">)</span> —<wbr></wbr> introduces a
quasipattern, in which identifiers match symbols. Like the
<span class="RktSym"><a href="quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">quasiquote</a></span> expression form, <span class="RktSym">unquote</span>
and <span class="RktSym">unquote-splicing</span> escape back to normal
patterns.</p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktRdr">,</span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktRdr">,</span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._odd~3f%29%29" class="RktValLink" data-pltdoc="x">odd?</a></span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 3)</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktVar">derived-pattern</span> —<wbr></wbr> matches a pattern defined by a
macro extension via <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxLink" data-pltdoc="x">define-match-expander</a></span>.</p></li></ul><p>Note that the matching process may destructure the input multiple times, and
may evaluate expressions embedded in patterns such as <span class="RktPn">(</span><span class="RktSym">app</span><span class="stt"> </span><span class="RktSym">expr</span><span class="stt"> </span><span class="RktVar">pat</span><span class="RktPn">)</span> in arbitrary order, or multiple times. Therefore, such
expressions must be safe to call multiple times, or in an order other than they
appear in the original program.</p><h4 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-part-tag=""Additional_Matching_Forms"">9.1<tt> </tt><a name="(part._.Additional_.Matching_.Forms)"></a>Additional Matching Forms</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match*))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match*</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">clause*</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">clause*</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">=></span><span class="hspace"> </span><span class="RktVar">id</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">#:when</span><span class="hspace"> </span><span class="RktVar">cond-expr</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Matches a sequence of values against each clause in order, matching
only when all patterns in a clause match. Each clause must have the
same number of patterns as the number of <span class="RktVar">val-expr</span>s.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="RktStxLink" data-pltdoc="x">match*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._add1%29%29" class="RktValLink" data-pltdoc="x">add1</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">4</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="RktStxLink" data-pltdoc="x">match*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVal">15</span><span class="hspace"> </span><span class="RktVal">17</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:when</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">diff-by-two</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'diff-by-two</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match/values))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2Fvalues%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match/values</a></span></span><span class="hspace"> </span><span class="RktVar">expr</span><span class="hspace"> </span><span class="RktVar">clause</span><span class="hspace"> </span><span class="RktVar">clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">If <span class="RktVar">expr</span> evaluates to <span class="RktSym">n</span> values, then match all <span class="RktSym">n</span>
values against the patterns in <span class="RktVar">clause</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span>. Each clause must contain
exactly <span class="RktSym">n</span> patterns. At least one clause is required to determine how
many values to expect from <span class="RktVar">expr</span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><table cellspacing="0" cellpadding="0" class="RktBlk RForeground"><tr><td><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._define/match))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define/match</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">head</span><span class="hspace"> </span><span class="RktVar">args</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">match*-clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">head</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">head</span><span class="hspace"> </span><span class="RktVar">args</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">args</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="hspace"> </span><span class="RktPn">.</span><span class="hspace"> </span><span class="RktVar">rest-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">arg</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">arg-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktVar">arg-id</span><span class="hspace"> </span><span class="RktVar">default-expr</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">keyword</span><span class="hspace"> </span><span class="RktVar">arg-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">keyword</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">arg-id</span><span class="hspace"> </span><span class="RktVar">default-expr</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">match*-clause</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">=></span><span class="hspace"> </span><span class="RktVar">id</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">#:when</span><span class="hspace"> </span><span class="RktVar">cond-expr</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">]</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Binds <span class="RktVar">id</span> to a procedure that is defined by pattern matching
clauses using <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="RktStxLink" data-pltdoc="x">match*</a></span>. Each clause takes a sequence of
patterns that correspond to the arguments in the function header.
The arguments are ordered as they appear in the function header for
matching purposes.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29" class="RktStxLink" data-pltdoc="x">define/match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">fact</span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">n</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace"> </span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">fact</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._sub1%29%29" class="RktValLink" data-pltdoc="x">sub1</a></span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">fact</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">120</span></p></td></tr></table></blockquote></td></tr></table></p><p>The function header may also contain optional or keyword arguments,
may have curried arguments, and may also contain a rest argument.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29" class="RktStxLink" data-pltdoc="x">define/match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">#:y</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym"><a href="regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29" class="RktValLink" data-pltdoc="x">regexp</a></span><span class="hspace"> </span><span class="RktVal">#rx"p+"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktRdr">,</span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktVal">"ape"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">#:y</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">5</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktVal">"dog"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29" class="RktStxLink" data-pltdoc="x">define/match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">g</span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym">rst</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">g</span><span class="hspace"> </span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">g</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">g</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-lambda))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-lambda</a></span></span><span class="hspace"> </span><span class="RktVar">clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">id</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="stt"> </span><span class="RktSym">id</span><span class="stt"> </span><span class="RktVar">clause</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="RktPn">)</span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-lambda*))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-lambda*</a></span></span><span class="hspace"> </span><span class="RktVar">clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span><span class="stt"> </span><span class="RktSym">lst</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="stt"> </span><span class="RktSym">lst</span><span class="stt"> </span><span class="RktVar">clause</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="RktPn">)</span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-lambda**))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%2A%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-lambda**</a></span></span><span class="hspace"> </span><span class="RktVar">clause*</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">args</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="RktStxLink" data-pltdoc="x">match*</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">args</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVar">clause*</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="RktPn">)</span>,
where the number of <span class="RktSym">args</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span> is computed from the number of patterns
appearing in each of the <span class="RktVar">clause*</span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-let))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-let</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Generalizes <span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%29%29" class="RktStxLink" data-pltdoc="x">let</a></span> to support pattern bindings. Each
<span class="RktVar">expr</span> is matched against its corresponding <span class="RktVar">pat</span> (the
match must succeed), and the bindings that <span class="RktVar">pat</span> introduces are
visible in the <span class="RktVar">body</span>s.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%29%29" class="RktStxLink" data-pltdoc="x">match-let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29" class="RktValLink" data-pltdoc="x">vector</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktVal">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(2 1 (1 2 3 4))</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-let*))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-let*</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%29%29" class="RktStxLink" data-pltdoc="x">match-let</a></span>, but generalizes <span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%2A%29%29" class="RktStxLink" data-pltdoc="x">let*</a></span>, so that the
bindings of each <span class="RktVar">pat</span> are available in each subsequent
<span class="RktVar">expr</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%2A%29%29" class="RktStxLink" data-pltdoc="x">match-let*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29" class="RktValLink" data-pltdoc="x">vector</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(1 2 3 4)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-let-values))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let-values%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-let-values</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%29%29" class="RktStxLink" data-pltdoc="x">match-let</a></span>, but generalizes <span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29" class="RktStxLink" data-pltdoc="x">let-values</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-let*-values))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%2A-values%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-let*-values</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%2A%29%29" class="RktStxLink" data-pltdoc="x">match-let*</a></span>, but generalizes <span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._let%2A-values%29%29" class="RktStxLink" data-pltdoc="x">let*-values</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-letrec))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-letrec%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-letrec</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-let%29%29" class="RktStxLink" data-pltdoc="x">match-let</a></span>, but generalizes <span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._letrec%29%29" class="RktStxLink" data-pltdoc="x">letrec</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-define))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-define</a></span></span><span class="hspace"> </span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Defines the names bound by <span class="RktVar">pat</span> to the values produced by
matching against the result of <span class="RktVar">expr</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define%29%29" class="RktStxLink" data-pltdoc="x">match-define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktSym">b</span></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match-define-values))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define-values%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match-define-values</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">pat</span><span class="hspace"> </span><span class="RktVar">pats</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define%29%29" class="RktStxLink" data-pltdoc="x">match-define</a></span> but for when expr produces multiple values.
Like match/values, it requires at least one pattern to determine the
number of values to expect.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-define-values%29%29" class="RktStxLink" data-pltdoc="x">match-define-values</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="values.html#%28def._%28%28quote._~23~25kernel%29._values%29%29" class="RktValLink" data-pltdoc="x">values</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktSym">b</span></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/match..rkt)._exn~3amisc~3amatch~3f))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._exn~3amisc~3amatch~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">exn:misc:match?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">A predicate for the exception raised in the case of a match failure.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._failure-cont))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._failure-cont%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">failure-cont</a></span></span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Continues matching as if the current pattern failed. Note that unlike
use of the <span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._~3d~3e%29%29" class="RktStxLink" data-pltdoc="x">=></a></span> form, this does <span style="font-style: italic">not</span> escape the current
context, and thus should only be used in tail position with respect to
the <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> form.</div></p><h4 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-part-tag=""Extending_match"">9.2<tt> </tt><a name="(part._.Extending_match)"></a>Extending <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span></h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._define-match-expander))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-match-expander</a></span></span><span class="hspace"> </span><span class="RktVar">id</span><span class="hspace"> </span><span class="RktVar">proc-expr</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-match-expander</a></span><span class="hspace"> </span><span class="RktVar">id</span><span class="hspace"> </span><span class="RktVar">proc-expr</span><span class="hspace"> </span><span class="RktVar">proc-expr</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Binds <span class="RktVar">id</span> to a <a name="(tech._match._expander)"></a><span style="font-style: italic">match expander</span>.</div></p><p>The first <span class="RktVar">proc-expr</span> sub-expression must evaluate to a
transformer that produces a <span class="RktVar">pat</span> for <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span>.
Whenever <span class="RktVar">id</span> appears as the beginning of a pattern, this
transformer is given, at expansion time, a syntax object
corresponding to the entire pattern (including <span class="RktVar">id</span>). The
pattern is replaced with the result of the transformer.</p><p>A transformer produced by a second <span class="RktVar">proc-expr</span> sub-expression is
used when <span class="RktVar">id</span> is used in an expression context. Using the
second <span class="RktVar">proc-expr</span>, <span class="RktVar">id</span> can be given meaning both
inside and outside patterns.</p><p>Match expanders are not invoked unless <span class="RktVar">id</span> appears in the first
position in a sequence. Instead, identifiers bound by <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxLink" data-pltdoc="x">define-match-expander</a></span>
are used as binding identifiers (like any other identifier) when they appear
anywhere except the first position in a sequence.</p><p><div class="SIntrapara">For example, to extend the pattern matcher and destructure syntax lists,
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">syntax-list?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-~3elist%29%29" class="RktValLink" data-pltdoc="x">syntax->list</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxLink" data-pltdoc="x">define-match-expander</a></span><span class="hspace"> </span><span class="RktSym">syntax-list</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._syntax-case%29%29" class="RktStxLink" data-pltdoc="x">syntax-case</a></span><span class="hspace"> </span><span class="RktSym">stx</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym">elts</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym">syntax-list?</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">app</span><span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-~3elist%29%29" class="RktValLink" data-pltdoc="x">syntax->list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">elts</span><span class="hspace"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-keyword-predicate</span><span class="hspace"> </span><span class="RktSym">keyword</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="stxops.html#%28def._%28%28lib._racket%2Fprivate%2Fstx..rkt%29._identifier~3f%29%29" class="RktValLink" data-pltdoc="x">identifier?</a></span><span class="hspace"> </span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="stxcmp.html#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29" class="RktValLink" data-pltdoc="x">free-identifier=?</a></span><span class="hspace"> </span><span class="RktSym">stx</span><span class="hspace"> </span><span class="RktSym">keyword</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">or-keyword?</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-keyword-predicate</span><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">and-keyword?</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-keyword-predicate</span><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p> </p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">syntax-list</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym">or-keyword?</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">"OOORRR!"</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">syntax-list</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym">and-keyword?</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">"AAANND!"</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'("OOORRR!" #<syntax:59:0 3> #<syntax:59:0 4>)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">6</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">syntax-list</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym">or-keyword?</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">"OOORRR!"</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">syntax-list</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace"> </span><span class="RktSym">and-keyword?</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">"AAANND!"</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">c</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'("AAANND!" #<syntax:60:0 5> #<syntax:60:0 6>)</span></p></td></tr></table></td></tr></table></blockquote></div></p><p><div class="SIntrapara">And here is an example showing how
<span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxLink" data-pltdoc="x">define-match-expander</a></span>-bound identifiers are
not treated specially unless they appear
in the first position of pattern sequence.
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxLink" data-pltdoc="x">define-match-expander</a></span><span class="hspace"> </span><span class="RktSym">nil</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">λ</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">λ</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">stx</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktRdr">#'</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">len</span><span class="hspace"> </span><span class="RktSym">l</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktSym">l</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">nil</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktSym">hd</span><span class="hspace"> </span><span class="RktSym">tl</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">len</span><span class="hspace"> </span><span class="RktSym">tl</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p> </p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">len</span><span class="hspace"> </span><span class="RktSym">nil</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">len</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktSym">nil</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">len</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktSym">nil</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr></table></td></tr></table></blockquote></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><p class="RForeground"><a name="(def._((lib._racket/match..rkt)._prop~3amatch-expander))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._prop~3amatch-expander%29%29" class="RktValDef RktValLink" data-pltdoc="x">prop:match-expander</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29" class="RktValLink" data-pltdoc="x">struct-type-property?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A <a href="structprops.html#%28tech._structure._type._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type property</span></a> to identify structure types that act
as <a href="#%28tech._match._expander%29" class="techoutside" data-pltdoc="x"><span class="techinside">match expanders</span></a> like the ones created by
<span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._define-match-expander%29%29" class="RktStxLink" data-pltdoc="x">define-match-expander</a></span>.</div></p><p>The property value must be an exact non-negative integer or a
procedure of one or two arguments. In the former case, the integer
designates a field within the structure that should contain a
procedure; the integer must be between <span class="RktVal">0</span> (inclusive) and the
number of non-automatic fields in the structure type (exclusive, not
counting supertype fields), and the designated field must also be
specified as immutable.</p><p>If the property value is a procedure of one argument, then the
procedure serves as the transformer for match expansion. If the property value is a procedure of two
arguments, then the first argument is the structure whose type has
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._prop~3amatch-expander%29%29" class="RktValLink" data-pltdoc="x">prop:match-expander</a></span> property, and the second argument is a
syntax object as for a <a href="#%28tech._match._expander%29" class="techoutside" data-pltdoc="x"><span class="techinside">match expander</span></a>..</p><p>If the property value is a <a href="syntax-model.html#%28tech._assignment._transformer%29" class="techoutside" data-pltdoc="x"><span class="techinside">assignment transformer</span></a>, then the wrapped
procedure is extracted with
<span class="RktSym"><a href="stxtrans.html#%28def._%28%28quote._~23~25kernel%29._set%21-transformer-procedure%29%29" class="RktValLink" data-pltdoc="x">set!-transformer-procedure</a></span> before it is called.</p><p>This binding is provided <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29" class="RktStxLink" data-pltdoc="x">for-syntax</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><p class="RForeground"><a name="(def._((lib._racket/match..rkt)._prop~3alegacy-match-expander))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._prop~3alegacy-match-expander%29%29" class="RktValDef RktValLink" data-pltdoc="x">prop:legacy-match-expander</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29" class="RktValLink" data-pltdoc="x">struct-type-property?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._prop~3amatch-expander%29%29" class="RktValLink" data-pltdoc="x">prop:match-expander</a></span>, but for the legacy match syntax.</div></p><p>This binding is provided <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29" class="RktStxLink" data-pltdoc="x">for-syntax</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/match..rkt)._match-expander~3f))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._match-expander~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">match-expander?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/match..rkt)._legacy-match-expander~3f))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._legacy-match-expander~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">legacy-match-expander?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Predicates for values which implement the appropriate match expander
properties.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>parameter</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/match..rkt)._match-equality-test))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._match-equality-test%29%29" class="RktValDef RktValLink" data-pltdoc="x">match-equality-test</a></span></span><span class="RktPn"></span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><a href="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="RktPn">(</span><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fmatch..rkt%29._match-equality-test%29%29" class="RktValDef RktValLink" data-pltdoc="x">match-equality-test</a></span></span><span class="hspace"> </span><span class="RktVar">comp-proc</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">comp-proc</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><a href="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">A <a href="eval-model.html#%28tech._parameter%29" class="techoutside" data-pltdoc="x"><span class="techinside">parameter</span></a> that determines the comparison procedure used to check
whether multiple uses of an identifier match the “same” value. The
default is <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match/derived))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2Fderived%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match/derived</a></span></span><span class="hspace"> </span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktVar">original-datum</span><span class="hspace"> </span><span class="RktVar">clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._match*/derived))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%2Fderived%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match*/derived</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">original-datum</span><span class="hspace"> </span><span class="RktVar">clause*</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> and <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2A%29%29" class="RktStxLink" data-pltdoc="x">match*</a></span> respectively, but includes a
sub-expression to be used as the source for all syntax errors within the form.
For example, <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%29%29" class="RktStxLink" data-pltdoc="x">match-lambda</a></span> expands to <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%2Fderived%29%29" class="RktStxLink" data-pltdoc="x">match/derived</a></span> so that
errors in the body of the form are reported in terms of <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match-lambda%29%29" class="RktStxLink" data-pltdoc="x">match-lambda</a></span>
instead of <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span>.</div></p><h4 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-part-tag=""Library_Extensions"">9.3<tt> </tt><a name="(part._.Library_.Extensions)"></a>Library Extensions</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._~3d~3d))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">==</a></span></span><span class="hspace"> </span><span class="RktVar">val</span><span class="hspace"> </span><span class="RktVar">comparator</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">==</a></span><span class="hspace"> </span><span class="RktVar">val</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">A <a href="#%28tech._match._expander%29" class="techoutside" data-pltdoc="x"><span class="techinside">match expander</span></a>
which checks if the matched value is the same as <span class="RktVar">val</span> when
compared by <span class="RktVar">comparator</span>. If <span class="RktVar">comparator</span> is
not provided, it defaults to <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29" class="RktStxLink" data-pltdoc="x">==</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29" class="RktStxLink" data-pltdoc="x">==</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29" class="RktValLink" data-pltdoc="x">eq?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'no</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29" class="RktStxLink" data-pltdoc="x">==</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">yes</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29" class="RktStxLink" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'yes</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/match..rkt)._struct*))"></a><span title="Provided from: racket/match, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._struct%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">struct*</a></span></span><span class="hspace"> </span><span class="RktVar">struct-id</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">field</span><span class="hspace"> </span><span class="RktVar">pat</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> pattern form that matches an instance of a structure
type named <span class="RktVar">struct-id</span>, where the field <span class="RktVar">field</span> in the
instance matches the corresponding <span class="RktVar">pat</span>.</div></p><p>Any field of <span class="RktVar">struct-id</span> may be omitted, and such fields can
occur in any order.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span><span class="hspace"> </span><span class="RktSym">tree</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">val</span><span class="hspace"> </span><span class="RktSym">left</span><span class="hspace"> </span><span class="RktSym">right</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-tree</span><span class="hspace"> </span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-tree</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._struct%2A%29%29" class="RktStxLink" data-pltdoc="x">struct*</a></span><span class="hspace"> </span><span class="RktSym">tree</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">val</span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">left</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fmatch..rkt%29._struct%2A%29%29" class="RktStxLink" data-pltdoc="x">struct*</a></span><span class="hspace"> </span><span class="RktSym">tree</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">right</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">val</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(0 1)</span></p></td></tr></table></blockquote></td></tr></table></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="Random_generation.html" title="backward to "8.11 Random generation"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "The Racket Reference"" data-pltdoc="x">up</a> <a href="control.html" title="forward to "10 Control Flow"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|