This file is indexed.

/usr/share/doc/racket/teachpack/2htdpabstraction.html is in racket-doc 6.7-3.

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
<!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>2.6&nbsp;Abstraction: "abstraction.rkt"</title><link rel="stylesheet" type="text/css" href="../scribble.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="../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="../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,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-style: italic">How to Design Programs</span> Teachpacks</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="htdp.html" class="tocviewlink" data-pltdoc="x">Ht<span class="mywbr"> &nbsp;</span>DP Teachpacks</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="2htdp2htdp.html" class="tocviewselflink" data-pltdoc="x">Ht<span class="mywbr"> &nbsp;</span>DP/<span class="mywbr"> &nbsp;</span>2e Teachpacks</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,&quot;tocview_1&quot;);">&#9660;</a></td><td>2&nbsp;</td><td><a href="2htdp2htdp.html" class="tocviewlink" data-pltdoc="x">Ht<span class="mywbr"> &nbsp;</span>DP/<span class="mywbr"> &nbsp;</span>2e Teachpacks</a></td></tr></table><div class="tocviewsublist" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.1&nbsp;</td><td><a href="2htdpbatch-io.html" class="tocviewlink" data-pltdoc="x">Batch Input/<span class="mywbr"> &nbsp;</span>Output:<span class="mywbr"> &nbsp;</span> <span class="stt">"batch-<wbr></wbr>io.rkt"</span><a name="(idx._(gentag._20._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.2&nbsp;</td><td><a href="2htdpimage-guide.html" class="tocviewlink" data-pltdoc="x">Image Guide</a></td></tr><tr><td align="right">2.3&nbsp;</td><td><a href="2htdpimage.html" class="tocviewlink" data-pltdoc="x">Images:<span class="mywbr"> &nbsp;</span> <span class="stt">"image.rkt"</span><a name="(idx._(gentag._21._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.4&nbsp;</td><td><a href="2htdpuniverse.html" class="tocviewlink" data-pltdoc="x">Worlds and the Universe:<span class="mywbr"> &nbsp;</span> <span class="stt">"universe.rkt"</span><a name="(idx._(gentag._22._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.5&nbsp;</td><td><a href="2htdpitunes.html" class="tocviewlink" data-pltdoc="x">i<span class="mywbr"> &nbsp;</span>Tunes:<span class="mywbr"> &nbsp;</span> <span class="stt">"itunes.rkt"</span><a name="(idx._(gentag._23._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.6&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Abstraction:<span class="mywbr"> &nbsp;</span> <span class="stt">"abstraction.rkt"</span><a name="(idx._(gentag._24._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.7&nbsp;</td><td><a href="2htdpPlanet_Cute_Images.html" class="tocviewlink" data-pltdoc="x">Planet Cute Images</a></td></tr><tr><td align="right">2.8&nbsp;</td><td><a href="2htdphtdp-port.html" class="tocviewlink" data-pltdoc="x">Porting World Programs to Universe</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,&quot;tocview_2&quot;);">&#9658;</a></td><td>2.6&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Abstraction:<span class="mywbr"> &nbsp;</span> <span class="stt">"abstraction.rkt"</span><a name="(idx._(gentag._24._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.6.1&nbsp;</td><td><a href="#%28part._x._abstraction%29" class="tocviewlink" data-pltdoc="x">Loops and Comprehensions</a></td></tr><tr><td align="right">2.6.2&nbsp;</td><td><a href="#%28part._x._matching%29" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">2.6.3&nbsp;</td><td><a href="#%28part._x._adt%29" class="tocviewlink" data-pltdoc="x">Algebraic Data Types</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">2.6.1<tt>&nbsp;</tt></span><a href="#%28part._x._abstraction%29" class="tocsubseclink" data-pltdoc="x">Loops and Comprehensions</a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> &nbsp;</span>list</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> &nbsp;</span>list</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2For%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> &nbsp;</span>or</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2For%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> &nbsp;</span>or</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fand%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> &nbsp;</span>and</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fand%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> &nbsp;</span>and</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fsum%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> &nbsp;</span>sum</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fsum%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> &nbsp;</span>sum</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fproduct%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> &nbsp;</span>product</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fproduct%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> &nbsp;</span>product</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fstring%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> &nbsp;</span>string</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fstring%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> &nbsp;</span>string</span></span></a></td></tr><tr><td><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">in-<wbr></wbr>range</span></span></a></td></tr><tr><td><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-naturals%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">in-<wbr></wbr>naturals</span></span></a></td></tr><tr><td><span class="tocsublinknumber">2.6.2<tt>&nbsp;</tt></span><a href="#%28part._x._matching%29" class="tocsubseclink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..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">2.6.3<tt>&nbsp;</tt></span><a href="#%28part._x._adt%29" class="tocsubseclink" data-pltdoc="x">Algebraic Data Types</a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._define-type%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define-<wbr></wbr>type</span></span></a></td></tr><tr><td><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._type-case%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">type-<wbr></wbr>case</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, &quot;6.7&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="2htdpitunes.html" title="backward to &quot;2.5 iTunes: &quot;itunes.rkt&quot;&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="2htdp2htdp.html" title="up to &quot;2 HtDP/2e Teachpacks&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="2htdpPlanet_Cute_Images.html" title="forward to &quot;2.7 Planet Cute Images&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h4 x-source-module="(lib &quot;teachpack/teachpack.scrbl&quot;)" x-source-pkg="htdp-doc" x-part-tag="&quot;abstraction&quot;">2.6<tt>&nbsp;</tt><a name="(part._abstraction)"></a><a name="(mod-path._2htdp/abstraction)"></a>Abstraction: <span class="stt">"abstraction.rkt"</span><a name="(idx._(gentag._24._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></h4><div class="SAuthorListBox"><span class="SAuthorList"><p class="author">Matthias Felleisen</p></span></div><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=htdp-langs&amp;rel=beginner.html%23%2528form._%2528%2528lib._lang%252Fhtdp-beginner..rkt%2529._require%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">2htdp/abstraction</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller">&nbsp;package:</span> <span class="stt">htdp-lib</span></span></td></tr></table></p><p>The <span class="stt">abstract.rkt</span> teachpack provides some additional abstraction
facilities: comprehensions and loops, matching, and algebraic data types.
Most of these are restricted versions of full-featured constructs in other
members of the Racket family so that students of HtDP/2e don&rsquo;t stumble
across syntactic oddities.</p><p>HtDP/2e introduces loops and matching in an intermezzo, with the sole
purpose of acknowledging the existence of powerful linguistic mechanisms.</p><p>Algebraic data types are provided for those who think teaching the features
of functional programming is more important than teaching universally
applicable ideas of program design.</p><p class="SHistory">Added in version 1.1 of package <span class="stt">htdp-lib</span>.</p><h5 x-source-module="(lib &quot;teachpack/teachpack.scrbl&quot;)" x-source-pkg="htdp-doc" x-part-prefixes="(&quot;x&quot;)" x-part-tag="&quot;abstraction&quot;">2.6.1<tt>&nbsp;</tt><a name="(part._x._abstraction)"></a>Loops and Comprehensions</h5><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for/list))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/list</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt">&nbsp;</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">comprehension-clause</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">name</span><span class="hspace">&nbsp;</span><span class="RktVar">clause-expr</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">evaluates <span class="RktVar">body-expr</span> for the <span style="font-weight: bold">parallel</span> sequences of values
 determined by the <span class="RktVar">comprehension-clause</span>s.</div></p><p>Each <span class="RktVar">comprehension-clause</span> binds its <span class="RktVar">name</span> in
 <span class="RktVar">body-expr</span>.</p><p><div class="SIntrapara">The <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span> expression evaluates all <span class="RktVar">clause-expr</span> to
 generate sequences of values. If a <span class="RktVar">clause-expr</span> evaluates to a
</div><div class="SIntrapara"><ul><li><p>list, its items make up the sequence values;</p></li><li><p>natural number <span class="RktSym">n</span>, the sequence of values consists of the
numbers <span class="RktVal">0</span>, <span class="RktVal">1</span>, ..., <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="stt"> </span><span class="RktSym">n</span><span class="stt"> </span><span class="RktVal">1</span><span class="RktPn">)</span>;</p></li><li><p>string, its one-character strings are the sequence items.</p></li></ul></div><div class="SIntrapara">For sequences generated by <span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="RktValLink" data-pltdoc="x">in-range</a></span> and <span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-naturals%29%29" class="RktValLink" data-pltdoc="x">in-naturals</a></span>, see below.</div></p><p><div class="SIntrapara">Finally, <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span> evaluates  <span class="RktVar">body-expr</span> with
 <span class="RktVar">name</span> ... successively bound to the values of the sequences
 determined by <span class="RktVar">clause-expr</span> ...
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(0 1 2 3 4 5 6 7 8 9)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((0 a) (1 b))</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">"abc"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'("a" "b" "c")</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara">The evaluation stops when the shortest sequence is exhausted.
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="hspace">&nbsp;</span><span class="RktVal">c</span><span class="hspace">&nbsp;</span><span class="RktVal">d</span><span class="hspace">&nbsp;</span><span class="RktVal">e</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((0 a) (1 b))</span></p></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>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._x._((lib._teachpack/2htdp/abstraction..rkt)._for*/list))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/list</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">evaluates <span class="RktVar">body-expr</span> for the <span style="font-weight: bold">nested</span> sequences of values
 determined by the <span class="RktVar">comprehension-clause</span>s.</div></p><p>Each <span class="RktVar">comprehension-clause</span> binds its <span class="RktSym">name</span> in the
 expressions of the following <span class="RktVar">comprehension-clause</span>s as well as
 <span class="RktVar">body-expr</span>.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((0 a) (0 b) (1 a) (1 b))</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((1 0) (2 0) (2 1) (3 0) (3 1) (3 2) (4 0) (4 1) (4 2) (4 3))</span></p></td></tr></table></blockquote><p><div class="SIntrapara">With nesting, the evaluation does <span style="font-weight: bold">not</span> stop when the shortest sequence
 is exhausted because <span class="RktVar">comprehension-clause</span>s are evaluated in order:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="hspace">&nbsp;</span><span class="RktVal">c</span><span class="hspace">&nbsp;</span><span class="RktVal">d</span><span class="hspace">&nbsp;</span><span class="RktVal">e</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'((0 a) (0 b) (0 c) (0 d) (0 e) (1 a) (1 b) (1 c) (1 d) (1 e))</span></p></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>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._x._((lib._teachpack/2htdp/abstraction..rkt)._for/or))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2For%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/or</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span>. It produces the first non-<span class="RktVal">#false</span> value, if
 any, and <span class="RktVal">#false</span> otherwise.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2For%29%29" class="RktStxLink" data-pltdoc="x">for/or</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">"abcd"</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3d%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">string=?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"x"</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">#false</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></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">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2For%29%29" class="RktStxLink" data-pltdoc="x">for/or</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#false</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">#false</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for*/or))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2For%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/or</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span>. It produces the first non-<span class="RktVal">#false</span> value, if
 any, and <span class="RktVal">#false</span> otherwise.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2For%29%29" class="RktStxLink" data-pltdoc="x">for*/or</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3e%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">&gt;</a></span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#false</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for/and))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fand%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/and</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span>. If any evaluation of <span class="RktVar">body-expr</span> produces
 <span class="RktVal">#false</span>, the loop stops and returns <span class="RktVal">#false</span>, too; otherwise,
 the loop produces the result of the last evaluation of <span class="RktVar">body-expr</span>.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fand%29%29" class="RktStxLink" data-pltdoc="x">for/and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</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">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3e%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">&gt;</a></span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">#false</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></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">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fand%29%29" class="RktStxLink" data-pltdoc="x">for/and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</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">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3c%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">&lt;</a></span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktVal">#false</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><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for*/and))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fand%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/and</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span>. If any evaluation of <span class="RktVar">body-expr</span> produces
 <span class="RktVal">#false</span>, the loop stops and returns <span class="RktVal">#false</span>, too; otherwise,
 the loop produces the result of the last evaluation of <span class="RktVar">body-expr</span>.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fand%29%29" class="RktStxLink" data-pltdoc="x">for*/and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%7E3c%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">&lt;</a></span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#false</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(1 0)</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for/sum))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fsum%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/sum</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span>. It adds up the numbers that <span class="RktVar">body-expr</span>
 evaluates to.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fsum%29%29" class="RktStxLink" data-pltdoc="x">for/sum</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">8</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._max%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">max</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</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><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for*/sum))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fsum%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/sum</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span>. It adds up the numbers that <span class="RktVar">body-expr</span>
 evaluates to.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fsum%29%29" class="RktStxLink" data-pltdoc="x">for*/sum</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._min%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">min</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for/product))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fproduct%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/product</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span>. It multiplies the numbers that <span class="RktVar">body-expr</span>
 evaluates to.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fproduct%29%29" class="RktStxLink" data-pltdoc="x">for/product</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">1</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><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for*/product))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fproduct%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/product</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span>. It multiplies the numbers that <span class="RktVar">body-expr</span>
 evaluates to.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fproduct%29%29" class="RktStxLink" data-pltdoc="x">for*/product</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for/string))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fstring%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/string</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span>. It collects the one-character strings that
 <span class="RktVar">body-expr</span> evaluates to with <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=htdp-langs&amp;rel=beginner.html%23%2528def._htdp-beginner._%2528%2528lib._lang%252Fhtdp-beginner..rkt%2529._implode%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">implode</a></span>.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Fstring%29%29" class="RktStxLink" data-pltdoc="x">for/string</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">"abc"</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">int-&gt;string</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">string-&gt;int</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">"bcd"</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._for*/string))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fstring%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/string</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktVar">comprehension-clause</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">iterates over the sequences generated by the <span class="RktVar">comprehension-clause</span>s
 like <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span>. It collects the one-character strings that
 <span class="RktVar">body-expr</span> evaluates to with <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=htdp-langs&amp;rel=beginner.html%23%2528def._htdp-beginner._%2528%2528lib._lang%252Fhtdp-beginner..rkt%2529._implode%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">implode</a></span>.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2A%2Fstring%29%29" class="RktStxLink" data-pltdoc="x">for*/string</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktVal">"ab"</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">j</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">string-&gt;int</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">90</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">int-&gt;string</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">string-&gt;int</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">j</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">"abcdefgbcdefghi"</span></p></td></tr></table></blockquote><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._x._((lib._teachpack/2htdp/abstraction..rkt)._in-range))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="RktValDef RktValLink" data-pltdoc="x">in-range</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">start</span><span class="hspace">&nbsp;</span><span class="RktVar">end</span><span class="hspace">&nbsp;</span><span class="RktVar">step</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._sequence%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">sequence?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">start</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._natural-number%252Fc%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">natural-number/c</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">end</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._natural-number%252Fc%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">natural-number/c</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">step</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._natural-number%252Fc%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">natural-number/c</a></span></td></tr><tr><td><span class="RktPn">(</span><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="RktValDef RktValLink" data-pltdoc="x">in-range</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">end</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._sequence%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">sequence?</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">end</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._natural-number%252Fc%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">natural-number/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">generates a <span style="font-weight: bold">finite</span> sequence of natural numbers.</div></p><p>If <span class="RktVar">start</span>, <span class="RktVar">end</span>, and <span class="RktVar">step</span> are provided, the
 sequence consists of <span class="RktVar">start</span>, <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="stt"> </span><span class="RktVar">start</span><span class="stt"> </span><span class="RktVar">step</span><span class="RktPn">)</span>, <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="stt"> </span><span class="RktVar">start</span><span class="stt"> </span><span class="RktVar">step</span><span class="stt"> </span><span class="RktVar">step</span><span class="RktPn">)</span>, ...  until the sum is greater than or equal to
 <span class="RktVar">end</span>.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="RktValLink" data-pltdoc="x">in-range</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(1 4 7)</span></p></td></tr></table></blockquote><p><div class="SIntrapara">If only <span class="RktVar">end</span> is provided, <span class="RktVar">start</span> defaults to <span class="RktVal">0</span>
 and <span class="RktVar">step</span> to <span class="RktVal">1</span>:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="RktValLink" data-pltdoc="x">in-range</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(0 1 2)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-range%29%29" class="RktValLink" data-pltdoc="x">in-range</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">i</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(0 1 2)</span></p></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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._x._((lib._teachpack/2htdp/abstraction..rkt)._in-naturals))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-naturals%29%29" class="RktValDef RktValLink" data-pltdoc="x">in-naturals</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">start</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._sequence%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">sequence?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">start</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._natural-number%252Fc%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">natural-number/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">generates an <span style="font-weight: bold">infinite</span> sequence of natural numbers, starting with
  <span class="RktVar">start</span>.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">enumerate</span><span class="hspace">&nbsp;</span><span class="RktSym">a-list</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">a-list</span><span class="RktPn">]</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._in-naturals%29%29" class="RktValLink" data-pltdoc="x">in-naturals</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">i</span><span class="hspace">&nbsp;</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><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">enumerate</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">Maxwell</span><span class="hspace">&nbsp;</span><span class="RktVal">Einstein</span><span class="hspace">&nbsp;</span><span class="RktVal">Planck</span><span class="hspace">&nbsp;</span><span class="RktVal">Heisenberg</span><span class="hspace">&nbsp;</span><span class="RktVal">Feynman</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((1 Maxwell) (2 Einstein) (3 Planck) (4 Heisenberg) (5 Feynman))</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">enumerate</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">"Pinot noir"</span><span class="hspace">&nbsp;</span><span class="RktVal">"Pinot gris"</span><span class="hspace">&nbsp;</span><span class="RktVal">"Pinot blanc"</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((1 "Pinot noir") (2 "Pinot gris") (3 "Pinot blanc"))</span></p></td></tr></table></blockquote><h5 x-source-module="(lib &quot;teachpack/teachpack.scrbl&quot;)" x-source-pkg="htdp-doc" x-part-prefixes="(&quot;x&quot;)" x-part-tag="&quot;matching&quot;">2.6.2<tt>&nbsp;</tt><a name="(part._x._matching)"></a>Pattern Matching</h5><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._x._((lib._teachpack/2htdp/abstraction..rkt)._match))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">match</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">case-expr</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">pattern</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt">&nbsp;</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">pattern</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">name</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">literal-constant</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">cons</span><span class="hspace">&nbsp;</span><span class="RktVar">pattern</span><span class="hspace">&nbsp;</span><span class="RktVar">pattern</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">name</span><span class="hspace">&nbsp;</span><span class="RktVar">pattern</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace">&nbsp;</span><span class="RktVar">name</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">dispatches like a <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._cond%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">cond</a></span>, matching the result of <span class="RktVar">case-expr</span>
 sequentially against all <span class="RktVar">pattern</span>s. The first successful match
 triggers the evaluation of the matching <span class="RktVar">body-expr</span>, whose value is the
 result of the entire <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> expression.</div></p><p>The literal constants commonly used are numbers, strings, symbols, and
 <span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">)</span>.</p><p>Each pattern that contains <span class="RktVar">name</span>s binds these names in the
 corresponding <span class="RktVar">body-expr</span>.</p><p><div class="SIntrapara">Matching a value with a pattern proceeds according to the following rules.
 If the pattern is a
</div><div class="SIntrapara"><ul><li><p><span class="RktVar">name</span>, it matches any value;</p></li><li><p><span class="RktVar">literal-constant</span>, it matches only the literal constant;</p></li><li><p><span class="RktPn">(</span><span class="RktVar">cons</span><span class="stt"> </span><span class="RktSym">pattern_1</span><span class="stt"> </span><span class="RktSym">pattern_2</span><span class="RktPn">)</span>, it matches when the value is an
instance of <span class="RktVar">cons</span>, and its first/rest fields match <span class="RktSym">pattern_1</span>
and <span class="RktSym">pattern_2</span>, respectively;</p></li><li><p><span class="RktPn">(</span><span class="RktVar">name</span><span class="stt"> </span><span class="RktVar">pattern</span><span class="stt"> </span><span class="RktMeta"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._......%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">...</a></span><span class="RktPn">)</span>, it matches when the value is an instance of
the <span class="RktVar">name</span> structure type, and its field values match <span class="RktVar">pattern</span>
...;</p></li><li><p><span class="RktPn">(</span><span class="RktSym">?</span><span class="stt"> </span><span class="RktVar">name</span><span class="RktPn">)</span>, it matches when <span class="RktVar">name</span> refers to a predicate
function and the latter produces <span class="RktVal">#true</span> on the given value.</p></li></ul></div><div class="SIntrapara">Furthermore, if the given pattern is <span class="RktVar">name</span> and the value is
 <span class="RktSym">V</span>, <span class="RktVar">name</span> stands for <span class="RktSym">V</span> during the evaluation of the
 corresponding <span class="RktVar">body-expr</span>.</div></p><p><div class="SIntrapara">The following <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> expression distinguishes <span class="RktVar">cons</span>es with
<span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">)</span> in the second position from all others:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">last-item</span><span class="hspace">&nbsp;</span><span class="RktSym">l</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace">&nbsp;</span><span class="RktSym">l</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">cons</span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktVar">cons</span><span class="hspace">&nbsp;</span><span class="RktSym">fst</span><span class="hspace">&nbsp;</span><span class="RktSym">rst</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">last-item</span><span class="hspace">&nbsp;</span><span class="RktSym">rst</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">last-item</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="hspace">&nbsp;</span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'c</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara">With ?, a <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> can use a predicate to distinguish arbitrary values:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">is-it-odd-or-even</span><span class="hspace">&nbsp;</span><span class="RktSym">l</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace">&nbsp;</span><span class="RktSym">l</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._even%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">even?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">even</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._odd%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">odd?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktVal">'</span><span class="RktVal">odd</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">is-it-odd-or-even</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'odd</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">is-it-odd-or-even</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'even</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara">A <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> expression can also deal with structure instances:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-struct%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">doll</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">layer</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">inside</span><span class="hspace">&nbsp;</span><span class="RktSym">a-doll</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace">&nbsp;</span><span class="RktSym">a-doll</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">?</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">a-doll</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">doll</span><span class="hspace">&nbsp;</span><span class="RktSym">below</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">inside</span><span class="hspace">&nbsp;</span><span class="RktSym">below</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">inside</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-doll</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-doll</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">wood</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'wood</span></p></td></tr></table></blockquote></div><div class="SIntrapara">Note, however, that the pattern uses just <span class="RktSym">doll</span>, the name of the
structure type, not <span class="RktSym">make-doll</span>, the constructor name.</div></p><h5 x-source-module="(lib &quot;teachpack/teachpack.scrbl&quot;)" x-source-pkg="htdp-doc" x-part-prefixes="(&quot;x&quot;)" x-part-tag="&quot;adt&quot;">2.6.3<tt>&nbsp;</tt><a name="(part._x._adt)"></a>Algebraic Data Types</h5><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._x._((lib._teachpack/2htdp/abstraction..rkt)._define-type))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._define-type%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-type</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">type</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">variant</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">field</span><span class="hspace">&nbsp;</span><span class="RktVar">predicate</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt">&nbsp;</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">type</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">name</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">variant</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">name</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">field</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">name</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">predicate</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">name</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">defines structure types <span class="RktVar">variant</span> ... with fields
 <span class="RktVar">field</span> ..., respectively. In addition, it defines constructors
 that enforce that the field values satisfy the specified predicate. Finally,
 it introduce the name <span class="RktVar">type</span> as the name for the union of all
 <span class="RktVar">variant</span> structure types and <span class="RktSym">type?</span> as a predicate
 that determines whether a value belongs to this class of values.</div></p><p><div class="SIntrapara">Consider the following type definition:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._define-type%29%29" class="RktStxLink" data-pltdoc="x">define-type</a></span><span class="hspace">&nbsp;</span><span class="RktSym">BTree</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">leaf</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">info</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._number%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">number?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">node</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">left</span><span class="hspace">&nbsp;</span><span class="RktSym">BTree?</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">right</span><span class="hspace">&nbsp;</span><span class="RktSym">BTree?</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">It defines two structure types:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-struct%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">leaf</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">info</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-struct%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">node</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">left</span><span class="hspace">&nbsp;</span><span class="RktSym">right</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">The <span class="RktSym">make-leaf</span> constructor signals an error when applied to any other
 values but numbers, while <span class="RktSym">make-node</span> accepts only instances of
 <span class="RktSym">BTree</span>. Finally, <span class="RktSym">BTree?</span> is a predicate that recognizes such
 instances:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">42</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(leaf 42)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">make-node</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">42</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">21</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(node (leaf 42) (leaf 21))</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">BTree?</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-node</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">42</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">21</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr></table></blockquote></div><div class="SIntrapara">And here is how a constructor fails when applied to the wrong kind of values:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">four</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">make-leaf: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: (or/c undefined? number?)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: 'four</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: the 1st argument of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(-&gt; (or/c undefined? number?) leaf?)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">contract from: make-leaf</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">blaming: use</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(assuming the contract is correct)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">at: program:2.0</span></p></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>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._x._((lib._teachpack/2htdp/abstraction..rkt)._type-case))"></a><span title="Provided from: 2htdp/abstraction | Package: htdp-lib"><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._type-case%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">type-case</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">type</span><span class="hspace">&nbsp;</span><span class="RktVar">case-expr</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">variant</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">field</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">body-expr</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">dispatches like a <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._cond%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">cond</a></span>, matching the result of <span class="RktVar">case-expr</span> sequentially
 against all <span class="RktVar">variant</span>s. The first successful match triggers the
 evaluation of the matching <span class="RktVar">body-expr</span>, whose value is the result of
 the entire <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._type-case%29%29" class="RktStxLink" data-pltdoc="x">type-case</a></span> expression.</div></p><p>A <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._type-case%29%29" class="RktStxLink" data-pltdoc="x">type-case</a></span> expression also ensures that (1) the collection
 <span class="RktVar">variant</span> cases covers all variant structure type definitions in
 <span class="RktVar">type</span> and (2) that each <span class="RktVar">variant</span> clauses specifies as many fields as
 the definition of <span class="RktVar">type</span> specifies.</p><p><div class="SIntrapara">Assume that the following definition is placed in the scope of the above type
definition for <span class="RktSym">BTree</span>:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">depth</span><span class="hspace">&nbsp;</span><span class="RktSym">t</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._type-case%29%29" class="RktStxLink" data-pltdoc="x">type-case</a></span><span class="hspace">&nbsp;</span><span class="RktSym">BTree</span><span class="hspace">&nbsp;</span><span class="RktSym">t</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">leaf</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">info</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">node</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">left</span><span class="hspace">&nbsp;</span><span class="RktSym">right</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._max%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">max</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">depth</span><span class="hspace">&nbsp;</span><span class="RktSym">left</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">depth</span><span class="hspace">&nbsp;</span><span class="RktSym">right</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">This function definition uses a <span class="RktSym"><a href="#%28form._x._%28%28lib._teachpack%2F2htdp%2Fabstraction..rkt%29._type-case%29%29" class="RktStxLink" data-pltdoc="x">type-case</a></span> for <span class="RktSym">BTree</span> and the
 latter consists of two clauses: one for <span class="RktSym">leaf</span>s and one for
 <span class="RktSym">node</span>s. The function computes the depth of the given tree.</div></p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">depth</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">42</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">&gt; </span><span class="RktPn">(</span><span class="RktSym">depth</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-node</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">42</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-leaf</span><span class="hspace">&nbsp;</span><span class="RktVal">21</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr></table></blockquote><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, &quot;6.7&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="2htdpitunes.html" title="backward to &quot;2.5 iTunes: &quot;itunes.rkt&quot;&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="2htdp2htdp.html" title="up to &quot;2 HtDP/2e Teachpacks&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="2htdpPlanet_Cute_Images.html" title="forward to &quot;2.7 Planet Cute Images&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>