Commits

Konstantine Rybnikov committed 2eb6905

Copy to ru

Comments (0)

Files changed (299)

ru/2dball.png

Added
New image

ru/2dball_001.png

Added
New image

ru/blocks1.png

Added
New image

ru/blocks1_001.png

Added
New image

ru/blocks2.png

Added
New image

ru/blocks2_001.png

Added
New image

ru/blocks3.png

Added
New image

ru/blocks3_001.png

Added
New image
Added
New image

ru/bobh_001.png

Added
New image

ru/bracket-down.png

Added
New image

ru/bracket-down_001.png

Added
New image

ru/bracket-up.png

Added
New image

ru/bracket-up_001.png

Added
New image
Added
New image

ru/car0_001.png

Added
New image
Added
New image

ru/car1_001.png

Added
New image
Added
New image

ru/car2_001.png

Added
New image
Added
New image

ru/car3_001.png

Added
New image
Added
New image

ru/cat1_001.png

Added
New image
Added
New image

ru/cat2_001.png

Added
New image

ru/chameleon.png

Added
New image

ru/chameleon_001.png

Added
New image

ru/closed-closed.png

Added
New image

ru/closed-closed_001.png

Added
New image

ru/closed-open.png

Added
New image

ru/closed-open_001.png

Added
New image
Added
New image
Added
New image

ru/d2_001.png

Added
New image
Added
New image

ru/dd-posn.png

Added
New image

ru/dd-posn_001.png

Added
New image
Added
New image

ru/dd0_001.png

Added
New image
Added
New image

ru/dd1_001.png

Added
New image

ru/dd2-posn.png

Added
New image

ru/dd2-posn_001.png

Added
New image

ru/def-data-arrows.png

Added
New image

ru/def-data-arrows_001.png

Added
New image

ru/def-data-mutual-arrows.png

Added
New image

ru/def-data-mutual-arrows_001.png

Added
New image

ru/def-fun-arrows.png

Added
New image

ru/def-fun-arrows_001.png

Added
New image

ru/def-fun-mutual-arrows.png

Added
New image

ru/def-fun-mutual-arrows_001.png

Added
New image
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/scribble.css ::::: */
+
+.maincolumn, .refpara, .refelem, .tocset, .stt, .hspace, .refparaleft, .refelemleft { font-family: monospace; }
+.main, .refcontent, .tocview, .tocsub, .sroman, i { font-family: serif; }
+p, .SIntrapara { display: block; margin: 1em 0px; }
+h2 { margin-top: 0px; }
+table p { margin-top: 0px; margin-bottom: 0px; }
+body { color: black; background-color: rgb(255, 255, 255); }
+table td { padding-left: 0px; padding-right: 0px; }
+.maincolumn { width: 43em; margin-right: -40em; margin-left: 15em; }
+.main { text-align: left; }
+.navsettop, .navsetbottom { background-color: rgb(240, 240, 224); padding: 0.25em 0px; }
+.navsettop { margin-bottom: 1.5em; border-bottom: 2px solid rgb(224, 224, 192); }
+.navsetbottom { margin-top: 2em; border-top: 2px solid rgb(224, 224, 192); }
+.navleft { margin-left: 1ex; position: relative; float: left; white-space: nowrap; }
+.navright { margin-right: 1ex; position: relative; float: right; white-space: nowrap; }
+.nonavigation { color: rgb(224, 224, 224); }
+#contextindicator { position: fixed; background-color: rgb(204, 102, 255); color: rgb(0, 0, 0); font-family: monospace; font-weight: bold; padding: 2px 10px; display: none; right: 0px; bottom: 0px; }
+.refpara, .refelem { position: relative; float: right; left: 2em; height: 0em; width: 13em; margin: 0em -13em 0em 0em; }
+.refpara, .refparaleft { top: -1em; }
+.refcolumn { background-color: rgb(245, 245, 220); display: block; position: relative; width: 13em; font-size: 85%; border: 0.5em solid rgb(245, 245, 220); margin: 0px; }
+.refcontent { margin: 0px; }
+.refcontent p { margin-top: 0px; margin-bottom: 0px; }
+.tocset { position: relative; float: left; width: 12.5em; margin-right: 2em; }
+.tocset td { vertical-align: text-top; }
+.tocview { text-align: left; background-color: rgb(240, 240, 224); }
+.tocsub { text-align: left; margin-top: 0.5em; background-color: rgb(240, 240, 224); }
+.tocviewlist, .tocsublist { margin-left: 0.2em; margin-right: 0.2em; padding-top: 0.2em; padding-bottom: 0.2em; }
+.tocviewlist table { font-size: 82%; }
+.tocviewlisttopspace { margin-bottom: 1em; }
+.tocviewsublist, .tocviewsublistonly, .tocviewsublisttop, .tocviewsublistbottom { margin-left: 0.4em; border-left: 1px solid rgb(187, 187, 255); padding-left: 0.8em; }
+.tocviewsublist table, .tocviewsublistonly table, .tocviewsublisttop table, .tocviewsublistbottom table { font-size: 75%; }
+.tocviewtitle * { font-weight: bold; }
+.tocviewlink { text-decoration: none; color: blue; }
+.tocviewselflink { text-decoration: underline; color: blue; }
+.tocviewtoggle { text-decoration: none; color: blue; font-size: 75%; }
+.tocsublist td { padding-left: 1em; text-indent: -1em; }
+.tocsublinknumber { font-size: 82%; }
+.tocsubseclink { font-size: 82%; text-decoration: none; }
+.tocsubtitle { font-size: 82%; font-style: italic; margin: 0.2em; }
+blockquote { margin-left: 2em; }
+ol { list-style-type: decimal; }
+.SubFlow { display: block; margin: 0em; }
+.SCentered { text-align: center; }
+.mywbr { display: inline-block; height: 0px; width: 0px; font-size: 1px; }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/shared.css ::::: */
+
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/racket.css ::::: */
+
+.RktIn, .RktRdr, .RktPn, .RktMeta, .RktMod, .RktKw, .RktVar, .RktSym, .RktRes, .RktOut, .RktCmt, .RktVal, .RktBlk { font-family: monospace; white-space: inherit; }
+.RktSym { color: rgb(38, 38, 128); }
+.RktStxLink { text-decoration: none; color: black; }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/scribble-style.css ::::: */
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html class="a bunch of things">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>How to Design Programs, Second Edition</title><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]-->
+<link rel="stylesheet" type="text/css" href="default.css" media="all">
+</head>
+<body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">▼</a></td><td></td><td><a indepth="true" href="default.html" class="tocviewselflink" data-pltdoc="x">How to Design Programs, Second Edition</a></td></tr></tbody></table></div><div class="tocviewsublistonly" style="display: block;" id="tocview_0"><table cellpadding="0" cellspacing="0"><tbody><tr><td align="right"></td><td><a indepth="true" href="part_prologue_001.html" class="tocviewlink" data-pltdoc="x">Prologue:<span class="mywbr"> &nbsp;</span> How to Program</a></td></tr><tr><td align="right">I&nbsp;</td><td><a indepth="true" href="part_one_001.html" class="tocviewlink" data-pltdoc="x">Fixed-<wbr>Size Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i1-2_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> BSL</a></td></tr><tr><td align="right">II&nbsp;</td><td><a indepth="true" href="part_two_001.html" class="tocviewlink" data-pltdoc="x">Arbitrarily Large Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i2-3_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Quote, Unquote</a></td></tr><tr><td align="right">III&nbsp;</td><td><a indepth="true" href="part_three_001.html" class="tocviewlink" data-pltdoc="x">Abstraction</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="intermezzo__scope_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Scope</a></td></tr><tr><td align="right">IV&nbsp;</td><td><a indepth="true" href="part_4_001.html" class="tocviewlink" data-pltdoc="x">Intertwined Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i4-5_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Pattern Matching</a></td></tr><tr><td align="right">V&nbsp;</td><td><a indepth="true" href="part_five_001.html" class="tocviewlink" data-pltdoc="x">Generative Recursion</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i5-6_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Vectors</a></td></tr><tr><td align="right">VI&nbsp;</td><td><a indepth="true" href="part_six_001.html" class="tocviewlink" data-pltdoc="x">Accumulators</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="htdp2e-epilogue_001.html" class="tocviewlink" data-pltdoc="x">Epilogue</a></td></tr></tbody></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tbody><tr><td><span class="tocsublinknumber"></span><a href="#%28part._htdp2e%29" class="tocsubseclink" data-pltdoc="x">How to Design Programs, Second Edition</a></td></tr></tbody></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<span class="nonavigation">← prev</span>&nbsp;&nbsp;<span class="nonavigation">up</span>&nbsp;&nbsp;<a indepth="true" href="part_prologue_001.html" title="forward to &quot;Prologue: How to Program&quot;" data-pltdoc="x">next →</a></span>&nbsp;</div><h2><a name="(part._htdp2e)"></a>How to Design Programs, Second Edition</h2><p><span class="refelem"><span class="refcolumn"><span class="refcontent">©
+   2004–2013
+   Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi;
+   comments to: matthias at ccs.neu.edu</span></span></span></p><blockquote class="SubFlow"><table align="center" cellspacing="0" height="150"><tbody><tr><td><blockquote class="SCentered"><p>Matthias Felleisen,
+Robert Bruce Findler,
+Matthew Flatt,
+Shriram Krishnamurthi</p></blockquote></td></tr></tbody></table></blockquote><p></p><div class="SIntrapara"><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>Do you notice the italics? Italicized words refer to technical
+terms. Here they refer to books on programming currently in bookstores.</p></blockquote></blockquote></blockquote></div><div class="SIntrapara">Bad programming is easy. <span style="font-style: italic;">Idiots</span> can learn it in <span style="font-style: italic;">21
+days</span>, even if they are <span style="font-style: italic;">Dummies</span>.</div><p></p><p>Good programming requires thought, but <span style="font-weight: bold;">everyone</span> can do it and
+ <span style="font-weight: bold;">everyone</span> can experience the satisfaction that comes with it.  The
+ price is worth paying for the sheer joy of the discovery process, the
+ elegance of the result, and the commercial benefits of a
+ systematic program design process.</p><p>The goal of our book is to introduce readers of all ages and backgrounds to
+ the craft of designing programs systematically. We assume few
+ prerequisites: arithmetic, a tiny bit of middle school algebra, and the
+ willingness to think through issues. We promise that the travails will pay
+ off not just for future programmers but for anyone who has to follow a
+ process or create one for others.</p><p>We are grateful to Ada Brunstein, our editor at MIT Press, who gave us
+ permission to develop this second edition of "How to Design Programs"
+ on-line.</p><blockquote class="SCentered"><p>Tuesday, December 17th, 2013 4:21:02pm</p></blockquote><p><span style="font-weight: bold;">Note</span>: this document is the <span style="font-weight: bold;">draft release</span> of HtDP/2e. It
+is updated on a frequent basis.  The <a indepth="true" href="index.html"><span style="font-weight: bold;">stable
+version</span></a> is released in conjunction with the PLT software and is thus more
+suitable for teaching than this draft.</p><p><span style="font-weight: bold;">Acknowledgments</span>: We thank
+ Ennas Abdussalam, 
+ Saad Bashir, 
+ Steven Belknap,
+ Stephen Bloch,
+ Elijah Botkin, 
+ Anthony Carrico, 
+ Rodolfo Carvalho, 
+ Nelson Chiu, 
+ Jack Clay,
+ Richard Cleis, 
+ John Clements,
+ Christopher Felleisen,
+ Sebastian Felleisen,
+ Ryan Golbeck,
+ Josh Grams,
+ Jack Gitelson, 
+ Scott Greene, 
+ Kyle Gillette, 
+ Nadeem Abdul Hamid,
+ Jeremy Hanlon, 
+ Craig Holbrook, 
+ Wayne Iba, ,
+ Jordan Johnson,
+ Blake Johnson, 
+ Gregor Kiczales,
+ Eugene Kohlbecker,
+ Jackson Lawler,
+ Jay McCarthy,
+ Mike McHugh, 
+ Wade McReynolds, 
+ Ann E. Moskol,
+ Scott Newson, 
+ Paul Ojanen,
+ Prof. Robert Ordóñez, 
+ Laurent Orseau, 
+ Klaus Ostermann,
+ Sinan Pehlivanoglu,
+ Eric Parker, 
+ Nick Pleatsikas, 
+ Norman Ramsey,
+ Krishnan Ravikumar, 
+ Jacob Rubin, 
+ Luis Sanjuán,
+ Lisa Scheuing, 
+ Willi Schiegel, 
+ Vinit Shah, 
+ Nick Shelley, 
+ Stephen Siegel,
+ Joe Snikeris, 
+ Vincent St-Amour,
+ Marc Smith,
+ Dave Smylie,
+ Kevin Sullivan, 
+ Thanos Tsouanas, 
+ Yuwang Yin, 
+ David Van Horn,
+ Mitchell Wand,
+ Michael Wijaya, 
+ G. Clifford Williams, 
+ Ewan Whittaker-Walker, 
+ Julia Wlochowski, 
+and
+ Roelof Wobben
+for comments on previous drafts of this second edition.</p><p><span style="font-weight: bold;">Differences</span>: This second edition of “How to Design Programs”
+continues to present an introduction to systematic program design and
+problem solving. Here are some important differences:</p><ol><li><p>The recipes are applied in two different, typical settings:
+interactive graphical programs and so-called “batch” programs. The former
+mode of interaction is typical for games, the latter for data processing in
+business centers. Both kinds of programs are still created with our design
+recipes.</p></li><li><p>While testing has always been a part of the “How to Design
+Programs” philosophy, the software started supporting it properly only in
+2002, just after we had released the first edition. This new edition
+heavily relies on this testing support now.</p></li><li><p>This edition of the book drops the design of imperative programs. The
+old chapters remain available on-line. The material will flow into the next
+volume of the book, “How to Design Components.”</p></li><li><p>The book and its programs employ new libraries, also known as
+teachpacks. The preferred style is to link in these libraries via so-called
+<span class="RktSym"><a href="http://pre.racket-lang.org/docs/html/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span> specifications, but it is still possible to add teachpacks
+via a menu in DrRacket.</p></li><li><p></p><div class="SIntrapara">Finally, we decided to use a slightly different terminology:
+</div><div class="SIntrapara"><table cellpadding="1" cellspacing="0"><tbody><tr><td align="left" valign="top" width="400"><p>HtDP/1e</p></td><td align="left" valign="top" width="400"><p>HtDP/2e</p></td></tr><tr><td align="left" valign="top" width="400"><p>
+</p></td><td align="left" valign="top" width="400"><p>
+</p></td></tr><tr><td align="left" valign="top" width="400"><p>contract</p></td><td align="left" valign="top" width="400"><p>signature</p></td></tr><tr><td align="left" valign="top" width="400"><p>
+</p></td><td align="left" valign="top" width="400"><p>
+</p></td></tr><tr><td align="left" valign="top" width="400"><p>union</p></td><td align="left" valign="top" width="400"><p>itemization</p></td></tr></tbody></table></div><p></p></li></ol><div class="navsetbottom"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<span class="nonavigation">← prev</span>&nbsp;&nbsp;<span class="nonavigation">up</span>&nbsp;&nbsp;<a indepth="true" href="part_prologue_001.html" title="forward to &quot;Prologue: How to Program&quot;" data-pltdoc="x">next →</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div>
+
+</body></html>

ru/dir-and-files.png

Added
New image

ru/dir-and-files_001.png

Added
New image

ru/distance-between.png

Added
New image

ru/distance-between_001.png

Added
New image

ru/distance0.png

Added
New image

ru/distance0_001.png

Added
New image

ru/distancem.png

Added
New image

ru/distancem_001.png

Added
New image

ru/door-real.png

Added
New image

ru/door-real_001.png

Added
New image

ru/door-simu.png

Added
New image

ru/door-simu_001.png

Added
New image

ru/drracket-plain.png

Added
New image

ru/drracket-plain_001.png

Added
New image
Added
New image

ru/earth_001.png

Added
New image
Added
New image

ru/edit1_001.png

Added
New image
Added
New image

ru/edit2_001.png

Added
New image

ru/editor-all-good.png

Added
New image

ru/editor-all-good_001.png

Added
New image

ru/ex-poly1.png

Added
New image

ru/ex-poly1_001.png

Added
New image

ru/ex-poly2.png

Added
New image

ru/ex-poly2_001.png

Added
New image

ru/ex-poly3.png

Added
New image

ru/ex-poly3_001.png

Added
New image

ru/family-tree.png

Added
New image

ru/family-tree_001.png

Added
New image

ru/favicon.ico

Added
New image
Added
New image

ru/fc_001.png

Added
New image

ru/grid-scene.png

Added
New image

ru/grid-scene_001.png

Added
New image

ru/htdp2e-epilogue.css

+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/scribble.css ::::: */
+
+.maincolumn, .refpara, .refelem, .tocset, .stt, .hspace, .refparaleft, .refelemleft { font-family: monospace; }
+.main, .refcontent, .tocview, .tocsub, .sroman, i { font-family: serif; }
+p, .SIntrapara { display: block; margin: 1em 0px; }
+h3, h4, h5, h6, h7, h8 { margin-top: 1.75em; margin-bottom: 0.5em; }
+body { color: black; background-color: rgb(255, 255, 255); }
+table td { padding-left: 0px; padding-right: 0px; }
+.maincolumn { width: 43em; margin-right: -40em; margin-left: 15em; }
+.main { text-align: left; }
+.navsettop, .navsetbottom { background-color: rgb(240, 240, 224); padding: 0.25em 0px; }
+.navsettop { margin-bottom: 1.5em; border-bottom: 2px solid rgb(224, 224, 192); }
+.navsetbottom { margin-top: 2em; border-top: 2px solid rgb(224, 224, 192); }
+.navleft { margin-left: 1ex; position: relative; float: left; white-space: nowrap; }
+.navright { margin-right: 1ex; position: relative; float: right; white-space: nowrap; }
+.nonavigation { color: rgb(224, 224, 224); }
+#contextindicator { position: fixed; background-color: rgb(204, 102, 255); color: rgb(0, 0, 0); font-family: monospace; font-weight: bold; padding: 2px 10px; display: none; right: 0px; bottom: 0px; }
+.refpara, .refelem { position: relative; float: right; left: 2em; height: 0em; width: 13em; margin: 0em -13em 0em 0em; }
+.refcolumn { background-color: rgb(245, 245, 220); display: block; position: relative; width: 13em; font-size: 85%; border: 0.5em solid rgb(245, 245, 220); margin: 0px; }
+.refcontent { margin: 0px; }
+.tocset { position: relative; float: left; width: 12.5em; margin-right: 2em; }
+.tocset td { vertical-align: text-top; }
+.tocview { text-align: left; background-color: rgb(240, 240, 224); }
+.tocsub { text-align: left; margin-top: 0.5em; background-color: rgb(240, 240, 224); }
+.tocviewlist, .tocsublist { margin-left: 0.2em; margin-right: 0.2em; padding-top: 0.2em; padding-bottom: 0.2em; }
+.tocviewlist table { font-size: 82%; }
+.tocviewsublist, .tocviewsublistonly, .tocviewsublisttop, .tocviewsublistbottom { margin-left: 0.4em; border-left: 1px solid rgb(187, 187, 255); padding-left: 0.8em; }
+.tocviewsublist table, .tocviewsublistonly table, .tocviewsublisttop table, .tocviewsublistbottom table { font-size: 75%; }
+.tocviewtitle * { font-weight: bold; }
+.tocviewlink { text-decoration: none; color: blue; }
+.tocviewselflink { text-decoration: underline; color: blue; }
+.tocviewtoggle { text-decoration: none; color: blue; font-size: 75%; }
+.tocsublist td { padding-left: 1em; text-indent: -1em; }
+.tocsublinknumber { font-size: 82%; }
+.tocsubseclink { font-size: 82%; text-decoration: none; }
+.tocsubtitle { font-size: 82%; font-style: italic; margin: 0.2em; }
+blockquote { margin-left: 2em; }
+ol { list-style-type: decimal; }
+.SubFlow { display: block; margin: 0em; }
+.SCentered { text-align: center; }
+.mywbr { width: 0px; font-size: 1px; }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/shared.css ::::: */
+
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/scribble-style.css ::::: */
+

ru/htdp2e-epilogue.html

+<!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>Epilogue</title><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]-->
+<link rel="stylesheet" type="text/css" href="htdp2e-epilogue.css" media="all">
+</head>
+<body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist" style="margin-bottom: 1em;"><div class="tocviewtitle"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">▼</a></td><td></td><td><a indepth="true" href="index.html" class="tocviewlink" data-pltdoc="x">How to Design Programs, Second Edition</a></td></tr></tbody></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellpadding="0" cellspacing="0"><tbody><tr><td align="right"></td><td><a indepth="true" href="part_prologue.html" class="tocviewlink" data-pltdoc="x">Prologue:<span class="mywbr"> &nbsp;</span> How to Program</a></td></tr><tr><td align="right">I&nbsp;</td><td><a indepth="true" href="part_one.html" class="tocviewlink" data-pltdoc="x">Fixed-<wbr>Size Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i1-2.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> BSL</a></td></tr><tr><td align="right">II&nbsp;</td><td><a indepth="true" href="part_two.html" class="tocviewlink" data-pltdoc="x">Arbitrarily Large Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i2-3.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Quote, Unquote</a></td></tr><tr><td align="right">III&nbsp;</td><td><a indepth="true" href="part_three.html" class="tocviewlink" data-pltdoc="x">Abstraction</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="intermezzo__scope.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Scope</a></td></tr><tr><td align="right">IV&nbsp;</td><td><a indepth="true" href="part_4.html" class="tocviewlink" data-pltdoc="x">Intertwined Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i4-5.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Pattern Matching</a></td></tr><tr><td align="right">V&nbsp;</td><td><a indepth="true" href="part_five.html" class="tocviewlink" data-pltdoc="x">Generative Recursion</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i5-6.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Vectors</a></td></tr><tr><td align="right">VI&nbsp;</td><td><a indepth="true" href="part_six.html" class="tocviewlink" data-pltdoc="x">Accumulators</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="htdp2e-epilogue.html" class="tocviewselflink" data-pltdoc="x">Epilogue</a></td></tr></tbody></table></div></div><div class="tocviewlist"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;">•</td><td></td><td><a indepth="true" href="htdp2e-epilogue.html" class="tocviewselflink" data-pltdoc="x">Epilogue</a></td></tr></tbody></table></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tbody><tr><td><span class="tocsublinknumber"></span><a href="#%28part._computing%29" class="tocsubseclink" data-pltdoc="x">Computing</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._programming%29" class="tocsubseclink" data-pltdoc="x">Programming</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._moving-on%29" class="tocsubseclink" data-pltdoc="x">Moving On</a></td></tr></tbody></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a indepth="true" href="part_six.html" title="backward to &quot;VI Accumulators&quot;" data-pltdoc="x">← prev</a>&nbsp;&nbsp;<a indepth="true" href="index.html" title="up to &quot;How to Design Programs, Second Edition&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<span class="nonavigation">next →</span></span>&nbsp;</div><h3><a name="(part._htdp2e-epilogue)"></a>Epilogue</h3><a name="(part._chap~3ahtdp2e-epilogue)"></a><blockquote class="SubFlow"><p><span style="font-style: italic;">ROS: I mean, what exactly do you <span style="font-weight: bold;">do</span></span>?</p></blockquote><blockquote class="SubFlow"><p><span style="font-style: italic;">PLAYER: We keep to our usual stuff, more or less, only inside out.
+We do on stage things that are supposed to happen off.  Which is a kind
+of integrity, if you look on every exit as being an entrance somewhere
+else</span></p></blockquote><blockquote class="SubFlow"><p>—<wbr>Tom Stoppard <span style="font-weight: bold;">Rosencrantz and Guildenstern are Dead</span></p></blockquote><p>We have reached the end of this introduction to computing and program
+design. While there is more to learn about both subjects, this is a good
+point to stop, to summarize, and to look ahead.</p><h4><a name="(part._computing)"></a>Computing</h4><p>From elementary school to high school we learn to compute with one form of
+data: numbers. Our first use of numbers is to count real things, say, three
+apples, five friends, twelve bagels. Later we use numbers without any
+appeal to concrete objects, but we have learned that numbers represent
+information in the real world.</p><p>Computing with software is <span style="font-weight: bold;">algebra for all kinds of data</span>, not just
+numbers. Nowadays, computer programs process representations of music,
+molecules, law cases, electrical diagrams, architectures of houses, and
+poems. Fortunately, we have learned to represent information with other
+forms of data than just numbers. Otherwise, computing and programming would
+become extremely tedious tasks.</p><p>Above all, we shouldn’t forget that computing means manipulating data
+through proper basic operations.  Some operations create new values. Others
+extract values from values.  Yet others modify values.  Finally, there are
+also basic operations for determining to which class a piece of data
+belongs. Built-in operations and functions are of course just another class
+of data.  Definition is value creation; application is a form of value
+extraction.<span class="refelem"><span class="refcolumn"><span class="refcontent">An object in a language such as Java is a function
+with many different bodies. Each method represents a different way of
+extracting data from an object.</span></span></span></p><p>When we define a function, we combine basic data operations. There are two
+fundamental mechanisms for combining functions: function composition and
+conditional expressions. The former means that the result of one function
+becomes the argument of another one. The latter represents a choice among
+several possibilities. When we eventually apply a function, we trigger a
+computation.</p><p>In this book we have studied the laws of basic operations and the laws of
+operation combination. Using these laws we can understand, in principle,
+how any function processes its input data and how it produces its results
+and effects. Because the computer is extremely fast and good at using these
+laws, it can perform such evaluations for more data and for larger programs
+than we can do with paper and pencil.</p><h4><a name="(part._programming)"></a>Programming</h4><p>Programs consist of definitions and expressions. Large programs consist of
+hundreds and thousands of definitions and expressions. Programmers design
+functions, use other programmer’s functions, leave, start on the
+project. Without a strong discipline we cannot hope to produce software of
+high quality. The key to programming discipline is to understand the design
+of programs as a means to describe computations, which, in turn, is to
+manipulate data through combinations of basic operations.</p><p>For that reason, the design of every program—<wbr>whether it is small and for
+personal use or large and for business use—<wbr>must start with an analysis
+of the surrounding world of information and a description of the classes of
+data that represent the relevant information. If the classes are unusual or
+new, we make up examples so we understand the organization of the class
+description. After we understand the world of information surrounding our
+project and its data representation, we make a plan.</p><p>A project plan identifies what data we wish to produce from the data that
+the program will be given. In many cases, though, a program doesn’t process
+data in just one way but in many ways. For example, a program for managing
+bank accounts must handle deposits, withdrawals, interest calculations, tax
+form generation, and many other tasks. In other cases, a program may have
+to compute complex relationships. For example, a program for simulating a
+ping-pong game must compute the movement of the ball, bounces on the table,
+bounces from the paddle, paddle movements, etc.  In either case, we need to
+describe what the various ways of processing data are and how they relate
+to each other.  Then we rank them and start with the most important one. We
+develop a working product, make sure that it meets our specifications, and
+refine the product by adding more functions or taking care of more cases or
+both.</p><p>Designing a function requires a rigorous understanding of what it computes.
+Unless we can describe its purpose and its effect with concise statements,
+we can’t produce the function. In almost all cases, it helps to make up
+examples and work through the function’s computation by hand. For
+complicated functions or for functions that use generative recursion,
+we should include some examples with the purpose statements. The examples
+illustrate the purpose and effect statements for others who may have to
+read or modify the program.</p><p>Studying examples tends to suggest the basic design recipe. In most cases,
+the design of a function is structural, even if it uses an accumulator or
+structure mutation. In a few others, we must use generative recursion. For
+these cases, it is important to explain the method for generating new
+problems and to sketch why the computation terminates.</p><p>When the definition is complete, we must test the function. Testing
+discovers mistakes, which we are bound to make due to all kinds of
+reasons. The best testing process turns independently developed examples
+into test suites, that is, a bunch of expressions that apply the function
+to select input examples and compare its results and effects with expected
+results and effects (mostly) automatically. If a mismatch is discovered,
+the test suite reports a problem. The test suite should never be discarded,
+only commented out. Every time we modify the function, we must use the test
+suite to check that we didn’t introduce mistakes. If we changed the
+underlying process, we may have to adapt the test suite mutatis
+mutandis.</p><p>No matter how hard we work, a function (or program) isn’t done the first
+time it works for our test suite. We must consider whether the development
+of the function revealed new interesting examples and turn such examples
+into additional tests. And we must edit the program. In particular, we must
+use abstraction properly to eliminate all patterns wherever possible.</p><p>If we respect these guidelines, we will produce decent software. It will
+work because we understand why and how it works. Others who must modify or
+enhance this software will understand it, because we include sufficient
+information on its development process. Still, to produce great software,
+we must practice following these guidelines and also learn a lot more about
+computing and programming than a first book can teach.</p><h4><a name="(part._moving-on)"></a>Moving On</h4><p>The knowledge and design skills from this book are a good foundation for
+learning more about programming, computing, and even practical work on
+software. First, the skills are good for learning the currently fashionable
+collection of object-oriented languages,
+especially Java. The two languages
+share a philosophy of programming. In both settings, computing means
+dealing with data, and programming means describing classes of values and
+functions on them.  Unlike Racket, however, Java requires programmers to
+spell out the class descriptions in Java, not just in English, and to place
+function definitions with class descriptions. As a result, Java requires
+programmers to learn a lot of syntactic conventions and is unsuitable as a
+first language.</p><p></p><div class="SIntrapara">Second, a programmer must study the fundamental ideas of computing. Thus
+far, our studies have focused on the laws of computing for data-oriented
+programming languages.
+Using the programming skills from this book, we can
+design and implement a simulation of how the hardware computes. By doing so
+we see the laws of computing from a radically different perspective. The
+contrast points to a number of interesting questions:
+</div><div class="SIntrapara"><ol><li><p>The two mechanisms of computing are rather different. Can one
+mechanism compute what the other one can compute and vice versa?</p></li><li><p>The laws we have used are mathematical and abstract. They do not take
+into account any real-world limitations. Does this mean that we can compute
+whatever we wish?</p></li><li><p>The (simulated) hardware shows that computers have limitations. How
+do these limitations affect what we can compute?</p></li></ol></div><div class="SIntrapara">Research on these questions created the discipline of computing and still
+guides the design of most computing curricula.</div><p></p><p>Finally, the design knowledge of this book is enough to build some
+real-world programs in Racket. DrRacket with its built-in Web browser and
+email capabilities is such a program. Building large real-world programs,
+however, requires some more knowledge about the functions that Racket uses
+to create GUIs, to connect computers on a network, to script things such as
+shells, web servers, networks, databases, etc. No matter what you do now,
+don’t forget that good programming makes your life easy and fun.</p><blockquote class="SCentered"><p>Remember the design recipe, wherever you go.</p></blockquote><div class="navsetbottom"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a indepth="true" href="part_six.html" title="backward to &quot;VI Accumulators&quot;" data-pltdoc="x">← prev</a>&nbsp;&nbsp;<a indepth="true" href="index.html" title="up to &quot;How to Design Programs, Second Edition&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<span class="nonavigation">next →</span></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div>
+
+</body></html>

ru/htdp2e-epilogue_001.css

+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/scribble.css ::::: */
+
+.maincolumn, .refpara, .refelem, .tocset, .stt, .hspace, .refparaleft, .refelemleft { font-family: monospace; }
+.main, .refcontent, .tocview, .tocsub, .sroman, i { font-family: serif; }
+p, .SIntrapara { display: block; margin: 1em 0px; }
+h3, h4, h5, h6, h7, h8 { margin-top: 1.75em; margin-bottom: 0.5em; }
+body { color: black; background-color: rgb(255, 255, 255); }
+table td { padding-left: 0px; padding-right: 0px; }
+.maincolumn { width: 43em; margin-right: -40em; margin-left: 15em; }
+.main { text-align: left; }
+.navsettop, .navsetbottom { background-color: rgb(240, 240, 224); padding: 0.25em 0px; }
+.navsettop { margin-bottom: 1.5em; border-bottom: 2px solid rgb(224, 224, 192); }
+.navsetbottom { margin-top: 2em; border-top: 2px solid rgb(224, 224, 192); }
+.navleft { margin-left: 1ex; position: relative; float: left; white-space: nowrap; }
+.navright { margin-right: 1ex; position: relative; float: right; white-space: nowrap; }
+.nonavigation { color: rgb(224, 224, 224); }
+#contextindicator { position: fixed; background-color: rgb(204, 102, 255); color: rgb(0, 0, 0); font-family: monospace; font-weight: bold; padding: 2px 10px; display: none; right: 0px; bottom: 0px; }
+.refpara, .refelem { position: relative; float: right; left: 2em; height: 0em; width: 13em; margin: 0em -13em 0em 0em; }
+.refcolumn { background-color: rgb(245, 245, 220); display: block; position: relative; width: 13em; font-size: 85%; border: 0.5em solid rgb(245, 245, 220); margin: 0px; }
+.refcontent { margin: 0px; }
+.tocset { position: relative; float: left; width: 12.5em; margin-right: 2em; }
+.tocset td { vertical-align: text-top; }
+.tocview { text-align: left; background-color: rgb(240, 240, 224); }
+.tocsub { text-align: left; margin-top: 0.5em; background-color: rgb(240, 240, 224); }
+.tocviewlist, .tocsublist { margin-left: 0.2em; margin-right: 0.2em; padding-top: 0.2em; padding-bottom: 0.2em; }
+.tocviewlist table { font-size: 82%; }
+.tocviewlisttopspace { margin-bottom: 1em; }
+.tocviewsublist, .tocviewsublistonly, .tocviewsublisttop, .tocviewsublistbottom { margin-left: 0.4em; border-left: 1px solid rgb(187, 187, 255); padding-left: 0.8em; }
+.tocviewsublist table, .tocviewsublistonly table, .tocviewsublisttop table, .tocviewsublistbottom table { font-size: 75%; }
+.tocviewtitle * { font-weight: bold; }
+.tocviewlink { text-decoration: none; color: blue; }
+.tocviewselflink { text-decoration: underline; color: blue; }
+.tocviewtoggle { text-decoration: none; color: blue; font-size: 75%; }
+.tocsublist td { padding-left: 1em; text-indent: -1em; }
+.tocsublinknumber { font-size: 82%; }
+.tocsubseclink { font-size: 82%; text-decoration: none; }
+.tocsubtitle { font-size: 82%; font-style: italic; margin: 0.2em; }
+blockquote { margin-left: 2em; }
+ol { list-style-type: decimal; }
+.SubFlow { display: block; margin: 0em; }
+.SCentered { text-align: center; }
+.mywbr { display: inline-block; height: 0px; width: 0px; font-size: 1px; }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/shared.css ::::: */
+
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/scribble-style.css ::::: */
+

ru/htdp2e-epilogue_001.html

+<!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>Epilogue</title><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]-->
+<link rel="stylesheet" type="text/css" href="htdp2e-epilogue_001.css" media="all">
+</head>
+<body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">▼</a></td><td></td><td><a indepth="true" href="default.html" class="tocviewlink" data-pltdoc="x">How to Design Programs, Second Edition</a></td></tr></tbody></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellpadding="0" cellspacing="0"><tbody><tr><td align="right"></td><td><a indepth="true" href="part_prologue_001.html" class="tocviewlink" data-pltdoc="x">Prologue:<span class="mywbr"> &nbsp;</span> How to Program</a></td></tr><tr><td align="right">I&nbsp;</td><td><a indepth="true" href="part_one_001.html" class="tocviewlink" data-pltdoc="x">Fixed-<wbr>Size Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i1-2_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> BSL</a></td></tr><tr><td align="right">II&nbsp;</td><td><a indepth="true" href="part_two_001.html" class="tocviewlink" data-pltdoc="x">Arbitrarily Large Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i2-3_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Quote, Unquote</a></td></tr><tr><td align="right">III&nbsp;</td><td><a indepth="true" href="part_three_001.html" class="tocviewlink" data-pltdoc="x">Abstraction</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="intermezzo__scope_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Scope</a></td></tr><tr><td align="right">IV&nbsp;</td><td><a indepth="true" href="part_4_001.html" class="tocviewlink" data-pltdoc="x">Intertwined Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i4-5_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Pattern Matching</a></td></tr><tr><td align="right">V&nbsp;</td><td><a indepth="true" href="part_five_001.html" class="tocviewlink" data-pltdoc="x">Generative Recursion</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i5-6_001.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Vectors</a></td></tr><tr><td align="right">VI&nbsp;</td><td><a indepth="true" href="part_six_001.html" class="tocviewlink" data-pltdoc="x">Accumulators</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="htdp2e-epilogue_001.html" class="tocviewselflink" data-pltdoc="x">Epilogue</a></td></tr></tbody></table></div></div><div class="tocviewlist"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;">•</td><td></td><td><a indepth="true" href="htdp2e-epilogue_001.html" class="tocviewselflink" data-pltdoc="x">Epilogue</a></td></tr></tbody></table></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tbody><tr><td><span class="tocsublinknumber"></span><a href="#%28part._computing%29" class="tocsubseclink" data-pltdoc="x">Computing</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._programming%29" class="tocsubseclink" data-pltdoc="x">Programming</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._moving-on%29" class="tocsubseclink" data-pltdoc="x">Moving On</a></td></tr></tbody></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a indepth="true" href="part_six_001.html" title="backward to &quot;VI Accumulators&quot;" data-pltdoc="x">← prev</a>&nbsp;&nbsp;<a indepth="true" href="default.html" title="up to &quot;How to Design Programs, Second Edition&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<span class="nonavigation">next →</span></span>&nbsp;</div><h3><a name="(part._htdp2e-epilogue)"></a>Epilogue</h3><a name="(part._chap~3ahtdp2e-epilogue)"></a><blockquote class="SubFlow"><p><span style="font-style: italic;">ROS: I mean, what exactly do you <span style="font-weight: bold;">do</span></span>?</p></blockquote><blockquote class="SubFlow"><p><span style="font-style: italic;">PLAYER: We keep to our usual stuff, more or less, only inside out.
+We do on stage things that are supposed to happen off.  Which is a kind
+of integrity, if you look on every exit as being an entrance somewhere
+else</span></p></blockquote><blockquote class="SubFlow"><p>—<wbr>Tom Stoppard <span style="font-weight: bold;">Rosencrantz and Guildenstern are Dead</span></p></blockquote><p>We have reached the end of this introduction to computing and program
+design. While there is more to learn about both subjects, this is a good
+point to stop, to summarize, and to look ahead.</p><h4><a name="(part._computing)"></a>Computing</h4><p>From elementary school to high school we learn to compute with one form of
+data: numbers. Our first use of numbers is to count real things, say, three
+apples, five friends, twelve bagels. Later we use numbers without any
+appeal to concrete objects, but we have learned that numbers represent
+information in the real world.</p><p>Computing with software is <span style="font-weight: bold;">algebra for all kinds of data</span>, not just
+numbers. Nowadays, computer programs process representations of music,
+molecules, law cases, electrical diagrams, architectures of houses, and
+poems. Fortunately, we have learned to represent information with other
+forms of data than just numbers. Otherwise, computing and programming would
+become extremely tedious tasks.</p><p>Above all, we shouldn’t forget that computing means manipulating data
+through proper basic operations.  Some operations create new values. Others
+extract values from values.  Yet others modify values.  Finally, there are
+also basic operations for determining to which class a piece of data
+belongs. Built-in operations and functions are of course just another class
+of data.  Definition is value creation; application is a form of value
+extraction.<span class="refelem"><span class="refcolumn"><span class="refcontent">An object in a language such as Java is a function
+with many different bodies. Each method represents a different way of
+extracting data from an object.</span></span></span></p><p>When we define a function, we combine basic data operations. There are two
+fundamental mechanisms for combining functions: function composition and
+conditional expressions. The former means that the result of one function
+becomes the argument of another one. The latter represents a choice among
+several possibilities. When we eventually apply a function, we trigger a
+computation.</p><p>In this book we have studied the laws of basic operations and the laws of
+operation combination. Using these laws we can understand, in principle,
+how any function processes its input data and how it produces its results
+and effects. Because the computer is extremely fast and good at using these
+laws, it can perform such evaluations for more data and for larger programs
+than we can do with paper and pencil.</p><h4><a name="(part._programming)"></a>Programming</h4><p>Programs consist of definitions and expressions. Large programs consist of
+hundreds and thousands of definitions and expressions. Programmers design
+functions, use other programmer’s functions, leave, start on the
+project. Without a strong discipline we cannot hope to produce software of
+high quality. The key to programming discipline is to understand the design
+of programs as a means to describe computations, which, in turn, is to
+manipulate data through combinations of basic operations.</p><p>For that reason, the design of every program—<wbr>whether it is small and for
+personal use or large and for business use—<wbr>must start with an analysis
+of the surrounding world of information and a description of the classes of
+data that represent the relevant information. If the classes are unusual or
+new, we make up examples so we understand the organization of the class
+description. After we understand the world of information surrounding our
+project and its data representation, we make a plan.</p><p>A project plan identifies what data we wish to produce from the data that
+the program will be given. In many cases, though, a program doesn’t process
+data in just one way but in many ways. For example, a program for managing
+bank accounts must handle deposits, withdrawals, interest calculations, tax
+form generation, and many other tasks. In other cases, a program may have
+to compute complex relationships. For example, a program for simulating a
+ping-pong game must compute the movement of the ball, bounces on the table,
+bounces from the paddle, paddle movements, etc.  In either case, we need to
+describe what the various ways of processing data are and how they relate
+to each other.  Then we rank them and start with the most important one. We
+develop a working product, make sure that it meets our specifications, and
+refine the product by adding more functions or taking care of more cases or
+both.</p><p>Designing a function requires a rigorous understanding of what it computes.
+Unless we can describe its purpose and its effect with concise statements,
+we can’t produce the function. In almost all cases, it helps to make up
+examples and work through the function’s computation by hand. For
+complicated functions or for functions that use generative recursion,
+we should include some examples with the purpose statements. The examples
+illustrate the purpose and effect statements for others who may have to
+read or modify the program.</p><p>Studying examples tends to suggest the basic design recipe. In most cases,
+the design of a function is structural, even if it uses an accumulator or
+structure mutation. In a few others, we must use generative recursion. For
+these cases, it is important to explain the method for generating new
+problems and to sketch why the computation terminates.</p><p>When the definition is complete, we must test the function. Testing
+discovers mistakes, which we are bound to make due to all kinds of
+reasons. The best testing process turns independently developed examples
+into test suites, that is, a bunch of expressions that apply the function
+to select input examples and compare its results and effects with expected
+results and effects (mostly) automatically. If a mismatch is discovered,
+the test suite reports a problem. The test suite should never be discarded,
+only commented out. Every time we modify the function, we must use the test
+suite to check that we didn’t introduce mistakes. If we changed the
+underlying process, we may have to adapt the test suite mutatis
+mutandis.</p><p>No matter how hard we work, a function (or program) isn’t done the first
+time it works for our test suite. We must consider whether the development
+of the function revealed new interesting examples and turn such examples
+into additional tests. And we must edit the program. In particular, we must
+use abstraction properly to eliminate all patterns wherever possible.</p><p>If we respect these guidelines, we will produce decent software. It will
+work because we understand why and how it works. Others who must modify or
+enhance this software will understand it, because we include sufficient
+information on its development process. Still, to produce great software,
+we must practice following these guidelines and also learn a lot more about
+computing and programming than a first book can teach.</p><h4><a name="(part._moving-on)"></a>Moving On</h4><p>The knowledge and design skills from this book are a good foundation for
+learning more about programming, computing, and even practical work on
+software. First, the skills are good for learning the currently fashionable
+collection of object-oriented languages,
+especially Java. The two languages
+share a philosophy of programming. In both settings, computing means
+dealing with data, and programming means describing classes of values and
+functions on them.  Unlike Racket, however, Java requires programmers to
+spell out the class descriptions in Java, not just in English, and to place
+function definitions with class descriptions. As a result, Java requires
+programmers to learn a lot of syntactic conventions and is unsuitable as a
+first language.</p><p></p><div class="SIntrapara">Second, a programmer must study the fundamental ideas of computing. Thus
+far, our studies have focused on the laws of computing for data-oriented
+programming languages.
+Using the programming skills from this book, we can
+design and implement a simulation of how the hardware computes. By doing so
+we see the laws of computing from a radically different perspective. The
+contrast points to a number of interesting questions:
+</div><div class="SIntrapara"><ol><li><p>The two mechanisms of computing are rather different. Can one
+mechanism compute what the other one can compute and vice versa?</p></li><li><p>The laws we have used are mathematical and abstract. They do not take
+into account any real-world limitations. Does this mean that we can compute
+whatever we wish?</p></li><li><p>The (simulated) hardware shows that computers have limitations. How
+do these limitations affect what we can compute?</p></li></ol></div><div class="SIntrapara">Research on these questions created the discipline of computing and still
+guides the design of most computing curricula.</div><p></p><p>Finally, the design knowledge of this book is enough to build some
+real-world programs in Racket. DrRacket with its built-in Web browser and
+email capabilities is such a program. Building large real-world programs,
+however, requires some more knowledge about the functions that Racket uses
+to create GUIs, to connect computers on a network, to script things such as
+shells, web servers, networks, databases, etc. No matter what you do now,
+don’t forget that good programming makes your life easy and fun.</p><blockquote class="SCentered"><p>Remember the design recipe, wherever you go.</p></blockquote><div class="navsetbottom"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a indepth="true" href="part_six_001.html" title="backward to &quot;VI Accumulators&quot;" data-pltdoc="x">← prev</a>&nbsp;&nbsp;<a indepth="true" href="default.html" title="up to &quot;How to Design Programs, Second Edition&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<span class="nonavigation">next →</span></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div>
+
+</body></html>
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/scribble.css ::::: */
+
+.maincolumn, .refpara, .refelem, .tocset, .stt, .hspace, .refparaleft, .refelemleft { font-family: monospace; }
+.main, .refcontent, .tocview, .tocsub, .sroman, i { font-family: serif; }
+p, .SIntrapara { display: block; margin: 1em 0px; }
+h3, h4, h5, h6, h7, h8 { margin-top: 1.75em; margin-bottom: 0.5em; }
+table p { margin-top: 0px; margin-bottom: 0px; }
+body { color: black; background-color: rgb(255, 255, 255); }
+table td { padding-left: 0px; padding-right: 0px; }
+.maincolumn { width: 43em; margin-right: -40em; margin-left: 15em; }
+.main { text-align: left; }
+.navsettop, .navsetbottom { background-color: rgb(240, 240, 224); padding: 0.25em 0px; }
+.navsettop { margin-bottom: 1.5em; border-bottom: 2px solid rgb(224, 224, 192); }
+.navsetbottom { margin-top: 2em; border-top: 2px solid rgb(224, 224, 192); }
+.navleft { margin-left: 1ex; position: relative; float: left; white-space: nowrap; }
+.navright { margin-right: 1ex; position: relative; float: right; white-space: nowrap; }
+#contextindicator { position: fixed; background-color: rgb(204, 102, 255); color: rgb(0, 0, 0); font-family: monospace; font-weight: bold; padding: 2px 10px; display: none; right: 0px; bottom: 0px; }
+.refpara, .refelem { position: relative; float: right; left: 2em; height: 0em; width: 13em; margin: 0em -13em 0em 0em; }
+.refcolumn { background-color: rgb(245, 245, 220); display: block; position: relative; width: 13em; font-size: 85%; border: 0.5em solid rgb(245, 245, 220); margin: 0px; }
+.refcontent { margin: 0px; }
+.tocset { position: relative; float: left; width: 12.5em; margin-right: 2em; }
+.tocset td { vertical-align: text-top; }
+.tocview { text-align: left; background-color: rgb(240, 240, 224); }
+.tocsub { text-align: left; margin-top: 0.5em; background-color: rgb(240, 240, 224); }
+.tocviewlist, .tocsublist { margin-left: 0.2em; margin-right: 0.2em; padding-top: 0.2em; padding-bottom: 0.2em; }
+.tocviewlist table { font-size: 82%; }
+.tocviewsublist, .tocviewsublistonly, .tocviewsublisttop, .tocviewsublistbottom { margin-left: 0.4em; border-left: 1px solid rgb(187, 187, 255); padding-left: 0.8em; }
+.tocviewsublist table, .tocviewsublistonly table, .tocviewsublisttop table, .tocviewsublistbottom table { font-size: 75%; }
+.tocviewtitle * { font-weight: bold; }
+.tocviewlink { text-decoration: none; color: blue; }
+.tocviewselflink { text-decoration: underline; color: blue; }
+.tocviewtoggle { text-decoration: none; color: blue; font-size: 75%; }
+.tocsublist td { padding-left: 1em; text-indent: -1em; }
+.tocsublinknumber { font-size: 82%; }
+.tocsubseclink { font-size: 82%; text-decoration: none; }
+.tocsubtitle { font-size: 82%; font-style: italic; margin: 0.2em; }
+.nobreak { white-space: nowrap; }
+.stt {  }
+blockquote { margin-left: 2em; }
+ol { list-style-type: decimal; }
+.SCodeFlow { display: block; margin: 0em 1em; white-space: nowrap; }
+.SubFlow { display: block; margin: 0em; }
+.hspace {  }
+.techoutside { text-decoration: underline; color: rgb(176, 176, 176); }
+.techoutside:hover { text-decoration: underline; color: blue; }
+.techinside { color: black; }
+.techinside:hover { color: blue; }
+.techoutside:hover > .techinside { color: inherit; }
+.mywbr { width: 0px; font-size: 1px; }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/shared.css ::::: */
+
+.Figure { border: 1px solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(238, 238, 238); }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/racket.css ::::: */
+
+.RktIn, .RktRdr, .RktPn, .RktMeta, .RktMod, .RktKw, .RktVar, .RktSym, .RktRes, .RktOut, .RktCmt, .RktVal, .RktBlk { font-family: monospace; white-space: inherit; }
+.RktIn { color: rgb(204, 102, 51); background-color: rgb(238, 238, 238); }
+.RktInBG { background-color: rgb(238, 238, 238); }
+.RktPn { color: rgb(132, 60, 36); }
+.RktMeta { color: black; }
+.RktErr { color: red; font-style: italic; }
+.RktVar { color: rgb(38, 38, 128); font-style: italic; }
+.RktSym { color: rgb(38, 38, 128); }
+.RktValLink { text-decoration: none; color: blue; }
+.RktStxLink { text-decoration: none; color: black; }
+.RktCmt { color: rgb(194, 116, 31); }
+.RktVal { color: rgb(34, 139, 34); }
+.RktBlk { white-space: inherit; text-align: left; }
+.RktBlk tr { white-space: inherit; }
+.RktBlk td { vertical-align: baseline; white-space: inherit; }
+.highlighted { background-color: rgb(221, 221, 255); }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/figure.css ::::: */
+
+.Centertext { text-align: center; margin: 0px; }
+.Figure, .FigureMulti, .FigureMultiWide, .Herefigure { margin: 1em 0px; border: 1px solid rgb(24, 24, 255); }
+.Figure, .FigureMulti, .Herefigure { width: 100%; }
+.Centerfigure { text-align: center; margin: 0px; }
+.Leftfigure { text-align: left; margin: 0px; }
+.FigureInside { margin: 1em; }
+/* ::::: http://www.ccs.neu.edu/home/matthias/HtDP2e/scribble-style.css ::::: */
+
+<!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>Intermezzo: BSL</title><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]-->
+<link rel="stylesheet" type="text/css" href="i1-2.css" media="all">
+</head>
+<body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist" style="margin-bottom: 1em;"><div class="tocviewtitle"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">▼</a></td><td></td><td><a indepth="true" href="index.html" class="tocviewlink" data-pltdoc="x">How to Design Programs, Second Edition</a></td></tr></tbody></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellpadding="0" cellspacing="0"><tbody><tr><td align="right"></td><td><a indepth="true" href="part_prologue.html" class="tocviewlink" data-pltdoc="x">Prologue:<span class="mywbr"> &nbsp;</span> How to Program</a></td></tr><tr><td align="right">I&nbsp;</td><td><a indepth="true" href="part_one.html" class="tocviewlink" data-pltdoc="x">Fixed-<wbr>Size Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i1-2.html" class="tocviewselflink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> BSL</a></td></tr><tr><td align="right">II&nbsp;</td><td><a indepth="true" href="part_two.html" class="tocviewlink" data-pltdoc="x">Arbitrarily Large Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i2-3.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Quote, Unquote</a></td></tr><tr><td align="right">III&nbsp;</td><td><a indepth="true" href="part_three.html" class="tocviewlink" data-pltdoc="x">Abstraction</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="intermezzo__scope.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Scope</a></td></tr><tr><td align="right">IV&nbsp;</td><td><a indepth="true" href="part_4.html" class="tocviewlink" data-pltdoc="x">Intertwined Data</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i4-5.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Pattern Matching</a></td></tr><tr><td align="right">V&nbsp;</td><td><a indepth="true" href="part_five.html" class="tocviewlink" data-pltdoc="x">Generative Recursion</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="i5-6.html" class="tocviewlink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> Vectors</a></td></tr><tr><td align="right">VI&nbsp;</td><td><a indepth="true" href="part_six.html" class="tocviewlink" data-pltdoc="x">Accumulators</a></td></tr><tr><td align="right"></td><td><a indepth="true" href="htdp2e-epilogue.html" class="tocviewlink" data-pltdoc="x">Epilogue</a></td></tr></tbody></table></div></div><div class="tocviewlist"><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 1em;">•</td><td></td><td><a indepth="true" href="i1-2.html" class="tocviewselflink" data-pltdoc="x">Intermezzo:<span class="mywbr"> &nbsp;</span> BSL</a></td></tr></tbody></table></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tbody><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3asynsem~3avocab%29" class="tocsubseclink" data-pltdoc="x">BSL:<span class="mywbr"> &nbsp;</span> Vocabulary</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3asynsem~3agrammar%29" class="tocsubseclink" data-pltdoc="x">BSL:<span class="mywbr"> &nbsp;</span> Grammar</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3asynsem~3asem%29" class="tocsubseclink" data-pltdoc="x">BSL:<span class="mywbr"> &nbsp;</span> Meaning</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3asynsem~3aerrors%29" class="tocsubseclink" data-pltdoc="x">BSL:<span class="mywbr"> &nbsp;</span> Errors</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3asynsem~3aand-or%29" class="tocsubseclink" data-pltdoc="x">Boolean Expressions</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3asynsem~3avar-defns~7d._%29" class="tocsubseclink" data-pltdoc="x">Constant Definitions</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._sec~3aint1-structs%29" class="tocsubseclink" data-pltdoc="x">Structure Type Definitions</a></td></tr><tr><td><span class="tocsublinknumber"></span><a href="#%28part._.B.S.L__.Tests%29" class="tocsubseclink" data-pltdoc="x">BSL:<span class="mywbr"> &nbsp;</span> Tests</a></td></tr></tbody></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft">&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a indepth="true" href="part_one.html" title="backward to &quot;I Fixed-Size Data&quot;" data-pltdoc="x">← prev</a>&nbsp;&nbsp;<a indepth="true" href="index.html" title="up to &quot;How to Design Programs, Second Edition&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a indepth="true" href="part_two.html" title="forward to &quot;II Arbitrarily Large Data&quot;" data-pltdoc="x">next →</a></span>&nbsp;</div><h3><a name="(part._i1-2)"></a>Intermezzo: BSL</h3><a name="(part._chap~3ai1-2)"></a><p>Thus far we have approached teaching BSL as if it were a natural
+ language.  Like toddlers, we first taught you the vocabulary of the
+ language with an intuitive understanding of its meaning. Next we exposed
+ you to some basic rules of how to compose and not to compose
+ sentences. Truly effective communication, however, requires some formal
+ study of a language’s vocabulary, grammar, and meaning.</p><p>A programming language is in many ways like a natural language. It has a
+ vocabulary and a grammar. The vocabulary is the collection of those words
+ from which we compose sentences in our language. A sentence in a
+ programming language is an expression or a function definition; the
+ language’s grammar dictates how to form complete sentences from
+ words. Programmers use the word <span style="font-style: italic;">syntax</span> to refer to the basic
+ vocabularies and grammars of programming languages.</p><p>Not all grammatical sentences are meaningful—<wbr>neither in English nor in a
+ programming language. For example, the English sentence “the cat is
+ round” is a meaningful sentence, but “the brick is a car” makes no
+ sense even though it is completely grammatical. To determine whether a
+ sentence is meaningful, we must know the <span style="font-style: italic;">meaning</span> of a language;
+ programmers call this <span style="font-style: italic;">semantics</span>.</p><p><span class="refelem"><span class="refcolumn"><span class="refcontent">The intermezzos of this book introduce ideas from programming
+languages that programmers must eventually understand and appreciate but
+are secondary to program design.</span></span></span>  In this intermezzo, we discuss the
+ meaning of BSL programs as if it were an extension of the familiar laws
+ of arithmetic and algebra.  After all, computation starts with this form
+ of simple mathematics, and we should understand the connection between
+ this mathematics and computing.  The first three sections present the
+ vocabulary, grammar, and meaning of a good portion of BSL. Based on
+ this new understanding of BSL, the fourth resumes our discussion of
+ errors. The remaining three sections revisit <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> and <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span>
+ expressions, constant definitions, and structure types.</p><h4><a name="(part._sec~3asynsem~3avocab)"></a>BSL: Vocabulary</h4><p><a href="#%28counter._%28figure._fig~3alex-beginner%29%29" data-pltdoc="x">Figure&nbsp;<span class="FigureRef">27</span></a> introduces and defines BSL’s basic
+ vocabulary. It consists of names that may or may not have meaning
+ according to BSL and of constants, also known as values and pieces of
+ data.</p><blockquote class="Figure"><blockquote class="Leftfigure"><blockquote class="FigureInside"><p></p><div class="SIntrapara">An <span class="RktVar">name</span> or a <span class="RktVar">variable</span> is a sequence of
+characters not including a space or one of the following:
+ <span class="RktInBG"><span class="hspace"></span><span class="RktIn">"</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">,</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">'</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">`</span><span class="hspace"></span></span>
+ <span class="RktInBG"><span class="hspace"></span><span class="RktIn">(</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">)</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">[</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">]</span><span class="hspace"></span></span>
+ <span class="RktInBG"><span class="hspace"></span><span class="RktIn">{</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">}</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">|</span><span class="hspace"></span></span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">;</span><span class="hspace"></span></span>
+ <span class="RktInBG"><span class="hspace"></span><span class="RktIn">#</span><span class="hspace"></span></span>:
+</div><div class="SIntrapara"><ul><li><p>A <span class="RktVar">primitive</span> is a name to which BSL assigns meaning, for
+example, <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span> or <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._sqrt%29%29" class="RktValLink" data-pltdoc="x">sqrt</a></span>.</p></li><li><p>A <span class="RktVar">variable</span> is a name without preassigned meaning.</p></li></ul></div><p></p><p></p><div class="SIntrapara">A <span class="RktVar">value</span>, also a called a piece of data, is one of:
+</div><div class="SIntrapara"><ul><li><p>A <span class="RktVar">number</span> is one of:
+        <span class="RktVal">1</span>,
+        <span class="RktVal"><span class="nobreak">-1</span></span>,
+        <span class="RktVal">3/5</span>,
+        <span class="RktVal">1.22</span>,
+        <span class="RktVal">1.22</span>,
+        <span class="RktVal">0+1i</span>,
+        and so on.
+The syntax for BSL numbers is complicated because it accommodates a range
+of formats: positive and negative numbers, fractions and decimal numbers,
+exact and inexact numbers, real and complex numbers, numbers in bases other
+than <span class="RktVal">10</span>, and more. Understanding the precise notation for numbers
+requires a thorough understanding of grammars and parsing, which is out of
+scope for this intermezzo.</p></li><li><p>A <span class="RktVar">boolean</span> is one of: <span class="RktVal">#t</span> or <span class="RktVal">#f</span>.</p></li><li><p>A <span class="RktVar">string</span> is one of:
+        <span class="RktVal">""</span>,
+        <span class="RktVal">"a"</span>,
+        <span class="RktVal">"doll"</span>,
+        <span class="RktVal">"he says \"hello world\" ok"</span>,
+        and so on.
+In general, it is a sequence of characters enclosed by a pair of
+<span class="RktInBG"><span class="hspace"></span><span class="RktIn">"</span><span class="hspace"></span></span>. For example, are all strings.</p></li><li><p>An <span class="RktVar">image</span> is a png, jpg, tiff, and various other formats. We
+intentionally omit a precise definition.</p></li></ul></div><div class="SIntrapara">We use <span class="RktSym">v</span>, <span class="RktSym">v-1</span>, <span class="RktSym">v-2</span> and the like when we wish to
+ say “any possible value.”</div><p></p></blockquote></blockquote><p class="Centertext"><span class="Legend"><span class="FigureTarget"><a name="(counter._(figure._fig~3alex-beginner))"></a>Figure&nbsp;27: </span>BSL core vocabulary</span></p></blockquote><p>Each of the explanations defines a set via a suggestive iteration of its
+ elements. Although it is possible to specify these collections in their
+ entirety and in a formal manner, we consider this superfluous here and
+ trust in your intuition. Keep in mind that each of these sets may come with
+ some extra elements.</p><h4><a name="(part._sec~3asynsem~3agrammar)"></a>BSL: Grammar</h4><p></p><div class="SIntrapara"><a href="#%28counter._%28figure._fig~3asyn-beginner%29%29" data-pltdoc="x">Figure&nbsp;<span class="FigureRef">28</span></a> shows a large part of the BSL grammar,
+ which—<wbr>in comparison to other languages—<wbr>is extremely simple. As to BSL’s
+ expressive power, don’t let the
+ looks deceive you. <span class="refelem"><span class="refcolumn"><span class="refcontent">Reading a grammar aloud makes it sound like a data
+definition. One could indeed use grammars to write down many of our data
+definitions.</span></span></span> The first action item is to discuss how to read such grammars. Each line with a <span class="RktInBG"><span class="hspace"></span><span class="RktIn">=</span><span class="hspace"></span></span> introduces
+ a <span style="font-style: italic;">syntactic category</span>; the best way to pronounce = as “is one
+ of” and | as “or.”  Wherever you see three dots, read as many
+ repetitions of what precedes the dots as you wish. This means, for
+ example, that a <span class="RktVar">program</span> is either nothing or a single occurrence of
+ <span class="RktVar">def-or-expr</span> or a sequence of two of them:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktVar">def-or-expr</span></td></tr><tr><td><span class="RktVar">def-or-expr</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">or three, four, five, or however many. Since this example is not particularly
+ illuminating, let us look at the second syntactic category. It says that
+ <span class="RktVar">definition</span> is either
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">because “as many as you wish” includes zero, or
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">which is one repetition, or
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">which uses two.</div><p></p><blockquote class="Figure"><blockquote class="Centerfigure"><blockquote class="FigureInside"><table cellspacing="0"><tbody><tr><td align="right" valign="baseline"><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">program</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">def-or-expr</span><span class="hspace">&nbsp;</span><span class="RktSym">...</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="hspace">&nbsp;&nbsp;</span><span class="RktVar">def-or-expr</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">definition</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">expr</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="hspace">&nbsp;&nbsp;</span><span class="RktVar">definition</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">variable</span><span class="hspace">&nbsp;</span><span class="RktSym">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</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"><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="hspace">&nbsp;&nbsp;</span><span class="RktVar">expr</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">variable</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">value</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">primitive</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktSym">...</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">variable</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktSym">...</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktSym">...</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">]</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktSym">...</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></blockquote><p class="Centertext"><span class="Legend"><span class="FigureTarget"><a name="(counter._(figure._fig~3asyn-beginner))"></a>Figure&nbsp;28: </span>BSL core grammar</span></p></blockquote><p>The final point about grammars concerns the three “words” that come in a
+ distinct font: <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span>, <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span>, and
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span>. According to the definition of BSL vocabulary, these
+ three words are names. What the vocabulary definition does not tell us is
+ that these names have a pre-defined meaning. In BSL, these words serve
+ as markers that differentiate some compound sentences from others, and in
+ acknowledgment of their role, such words are called <span style="font-style: italic;">keywords</span>.</p><p></p><div class="SIntrapara">Now we are ready to state the purpose of a grammar. The grammar of a
+ programming language dictates how to form sentences from the vocabulary of
+ the grammar. Some sentences are just elements of vocabulary. For example,
+ according to <a href="#%28counter._%28figure._fig~3asyn-beginner%29%29" data-pltdoc="x">figure&nbsp;<span class="FigureRef">28</span></a> <span class="RktVal">42</span> is a sentence of
+ BSL:
+</div><div class="SIntrapara"><ul><li><p>The first syntactic category says that a program is a
+<span class="RktVar">def-or-expr</span>.<span class="refelem"><span class="refcolumn"><span class="refcontent">In DrRacket, a program really consists
+of two distinct parts: the definitions area and the expressions in the
+interactions area.</span></span></span>  Expressions may refer to the definitions.</p></li><li><p>The second definition tells us that a <span class="RktVar">def-or-expr</span> is either
+a <span class="RktVar">definition</span> or an <span class="RktVar">expr</span>.</p></li><li><p>The last definition lists all ways of forming an
+<span class="RktVar">expr</span>, and the second one is <span class="RktVar">value</span>.</p></li></ul></div><div class="SIntrapara">Since we know from <a href="#%28counter._%28figure._fig~3alex-beginner%29%29" data-pltdoc="x">figure&nbsp;<span class="FigureRef">27</span></a> that <span class="RktVal">42</span> is a
+ value, we have a complete confirmation.</div><p></p><p>The interesting parts of the grammar show how to form compound sentences,
+ which are sentences built from other sentences. For example, the
+ <span class="RktVar">definition</span> part tells us that a function definition is formed by
+ using “(”, followed by the keyword <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span>, followed by another
+ “(”, followed by a sequence of at least two variables, followed by
+ “)”, followed by an <span class="RktVar">expr</span>, and closed by a right parenthesis
+ “)” that matches the very first one.  You can see from this example how
+ the leading keyword <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span> distinguishes definitions from
+ expressions.</p><p>Expressions, called <span class="RktVar">expr</span>, come in six flavors: variables,
+ constants, primitive applications, (function) applications, and two
+ varieties of <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span>itionals.  While the first two are atomic
+ sentences, the last four are compound sentences. Note how the keyword
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> distinguishes conditional expressions from primitive and
+ function applications.</p><p>Here are three examples of expressions: <span class="RktVal">"all"</span>, <span class="RktSym">x</span>, and
+ <span class="RktPn">(</span><span class="RktSym">f</span><span class="stt"> </span><span class="RktSym">x</span><span class="RktPn">)</span>. The first one belongs to the class of strings and is
+ therefore an expression. The second is a variable, and every variable is
+ an expression.  The third is a function application, because <span class="RktSym">f</span>
+ and <span class="RktSym">x</span> are variables.</p><p>In contrast, the following parenthesized sentences are not expressions:
+ <span class="RktPn">(</span><span class="RktSym">f</span><span class="stt"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktPn">)</span>, <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span class="stt"> </span><span class="RktSym">x</span><span class="RktPn">)</span>, and <span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="stt"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVal">10</span><span class="RktPn">)</span>.  The
+ first one partially matches the shape of a function application but it
+ uses <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span> as if it were a variable. The second one fails to be
+ a correct <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> expression because it contains a variable as the
+ second item and not a pair of expressions surrounded by parentheses. The
+ last one is neither a conditional nor an application because the first
+ part is an expression.</p><p>Finally, you may notice that the grammar does not mention white space:
+ blank spaces, tabs, and newlines.<span class="refelem"><span class="refcolumn"><span class="refcontent">Keep in mind that two kinds
+of readers study your BSL programs: people and DrRacket.</span></span></span> BSL is a
+ permissive language. As long as there is some white space between the
+ elements of any sequence in a program, DrRacket can understand your BSL
+ programs. Good programmers, however, may not like what you write. These
+ programmers use white space to make their programs easily readable. Most
+ importantly, they adopt a style that favors human readers over the
+ software applications that process programs (such as DrRacket). They pick up
+ this style from careful reading code examples in books, paying attention
+ to how it is formatted.</p><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3alegal-ex1))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;106. Explain why the following sentences are syntactically legal expressions</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktSym">x</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktSym">z</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktSym">z</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara"><img src="qed.png" alt=""></div><p></p></blockquote><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3aillegal-ex1))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;107. Explain why the following sentences are syntactically illegal</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span><span class="RktPn">(</span><span class="RktSym">l</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara"><img src="qed.png" alt=""></div><p></p></blockquote><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3alegal-def1))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;108. Explain why the following sentences are syntactically legal definitions</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara"><img src="qed.png" alt=""></div><p></p></blockquote><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3alegal-def1a))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;109. Explain why the following sentences are syntactically illegal</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktSym">z</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara"><img src="qed.png" alt=""></div><p></p></blockquote><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3aillegal-exp1))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;110. Pick the legal from the legal from illegal
+sentences in the following list:
+</div><div class="SIntrapara"><ol><li><p><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span></p></li><li><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="stt"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></p></li><li><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktVal">2</span><span class="stt"> </span><span class="RktVal">3</span><span class="RktPn">)</span></p></li></ol></div><div class="SIntrapara">Explain why the sentences are legal or illegal. Determine whether they
+belong the category <span class="RktVar">expr</span> or <span class="RktVar">definition</span>. <img src="qed.png" alt=""></div><p></p></blockquote><p>Note on Grammatical Terminology: The components of compound
+sentences have names. We have introduced some of these names on an informal
+basis. <a href="#%28counter._%28figure._fig~3aterminology%29%29" data-pltdoc="x">Figure&nbsp;<span class="FigureRef">29</span></a> provides a summary of the conventions.</p><blockquote class="Figure"><blockquote class="Leftfigure"><blockquote class="FigureInside"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">function application:</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktVar">function</span><span class="hspace">&nbsp;</span><span class="RktVar">argument</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace">&nbsp;</span><span class="RktVar">argument</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">function definition:</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">function-name</span><span class="hspace">&nbsp;</span><span class="RktVar">parameter</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace">&nbsp;</span><span class="RktVar">parameter</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">function-body</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">conditional expression:</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">cond-clause</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">cond-clause</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span class="RktCmt"> clause </span></td></tr><tr><td><span class="RktPn">[</span><span class="RktVar">condition</span><span class="hspace">&nbsp;</span><span class="RktVar">answer</span><span class="RktPn">]</span></td></tr></tbody></table></blockquote></blockquote></blockquote><p class="Centertext"><span class="Legend"><span class="FigureTarget"><a name="(counter._(figure._fig~3aterminology))"></a>Figure&nbsp;29: </span>Syntactic naming conventions</span></p></blockquote><p>In addition to the terminology of <a href="#%28counter._%28figure._fig~3aterminology%29%29" data-pltdoc="x">figure&nbsp;<span class="FigureRef">29</span></a>, we say
+<span style="font-style: italic;">function header</span> for second component of a definition.
+Accordingly, the expression component is called <span style="font-style: italic;">function body</span>.
+People who consider programming languages as a form of mathematics use
+<span style="font-style: italic;">left-hand side</span> for a header and <span style="font-style: italic;">right-hand side</span> for the
+body.</p><p>On occasion, you also hear or read the term <span style="font-style: italic;">actual arguments</span> for
+the arguments in a function application. People tend to use this
+terminology when they think of the value of the arguments, which they also
+called their meaning.</p><h4><a name="(part._sec~3asynsem~3asem)"></a>BSL: Meaning</h4><p>When DrRacket evaluates an expression, it uses nothing but the laws of
+ arithmetic and algebra to convert an expression into a value—<wbr>see
+ <a href="#%28counter._%28figure._fig~3alex-beginner%29%29" data-pltdoc="x">figure&nbsp;<span class="FigureRef">27</span></a>. In ordinary mathematics courses, values are
+ numbers. As you know from the figure, the values of BSL also include
+ <a indepth="true" href="part_one.html#(tech._boolean)" class="techoutside" data-pltdoc="x"><span class="techinside">Boolean</span></a>s, <a indepth="true" href="part_one.html#(tech._string)" class="techoutside" data-pltdoc="x"><span class="techinside">String</span></a>, and <a indepth="true" href="part_one.html#(tech._image)" class="techoutside" data-pltdoc="x"><span class="techinside">Image</span></a>s.  Note how the
+ collection of values is thus just a subset of the collection of
+ expressions.</p><p></p><div class="SIntrapara">The rules of evaluation come in two categories.  First, we need an infinite
+ number of rules like those of arithmetic to evaluate applications of
+ primitives:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span></td></tr><tr><td><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">But BSL arithmetic is more general than just number crunching. It
+ also includes rules for dealing with Boolean values, strings, and so on:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string~3d~3f%29%29" class="RktValLink" data-pltdoc="x">string=?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span></td></tr><tr><td><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">We use <span class="RktSym">==</span> to say that two expressions are equal according to
+ BSL.</div><p></p><p></p><div class="SIntrapara">Like in algebra, you can always replace equals with equals in expressions:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string-length%29%29" class="RktValLink" data-pltdoc="x">string-length</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string-append%29%29" class="RktValLink" data-pltdoc="x">string-append</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"hello"</span><span class="hspace">&nbsp;</span><span class="RktVal">"world"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">1</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">3</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string-length%29%29" class="RktValLink" data-pltdoc="x">string-length</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string-append%29%29" class="RktValLink" data-pltdoc="x">string-append</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">"hello"</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">"world"</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string-length%29%29" class="RktValLink" data-pltdoc="x">string-length</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">"helloworld"</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">10</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">4</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span></span><span class="highlighted"><span class="RktPn">)</span></span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span></td></tr></tbody></table></blockquote></div><p></p><p></p><div class="SIntrapara">Second, we need a rule from algebra to understand the application of a
+functions to arguments.  Suppose the program contains the definition
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x-1</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace">&nbsp;</span><span class="RktSym">x-n</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">f-body</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">Then an application of a function is governed by the law:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">v-1</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace">&nbsp;</span><span class="RktSym">v-n</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktSym">f-body</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">with all occurrences of </span><span class="RktSym">x-1</span><span class="RktCmt">... </span><span class="RktSym">x-n</span><span class="RktCmt"> </span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">replaced with </span><span class="RktSym">v-1</span><span class="RktCmt"> ... </span><span class="RktSym">v-n</span><span class="RktCmt">, respectively</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">Due to the history of languages such as BSL, we refer to this rule as the
+ <span style="font-style: italic;">beta</span> or <span style="font-style: italic;">beta-value</span> rule.</div><p></p><p></p><div class="SIntrapara">This rule is as general as possible, so it is best to look at a concrete
+ example. Say the definition is
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">poly</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._expt%29%29" class="RktValLink" data-pltdoc="x">expt</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">Then the first step in an evaluation of <span class="RktPn">(</span><span class="RktSym">poly</span><span class="stt"> </span><span class="RktVal">3</span><span class="stt"> </span><span class="RktVal">5</span><span class="RktPn">)</span> uses beta:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym">poly</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._expt%29%29" class="RktValLink" data-pltdoc="x">expt</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">8</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktVal">13</span></p></blockquote></div><div class="SIntrapara">For the rest, DrRacket uses plain arithmetic.</div><p></p><p></p><div class="SIntrapara">In addition to beta, we need a couple of rules that help us determine the value of
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> expressions.  These rules are algebraic rules but are not a
+ part of the standard algebra curriculum. When the first condition is
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span>, then the first <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span>-line disappears:
+</div><div class="SIntrapara"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">condition-1</span><span class="hspace">&nbsp;</span><span class="RktSym">answer-1</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><p></p></td><td align="center" valign="mid" width="30"><p><span class="RktSym">==</span></p></td><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">the first line disappeared </span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">condition-1</span><span class="hspace">&nbsp;</span><span class="RktSym">answer-1</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><p></p></td></tr></tbody></table></div><div class="SIntrapara">This rule has the name <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span style="font-style: italic;"></span><span style="vertical-align: sub; font-size: 80%;"><span style="font-style: italic;">false</span></span><span style="font-style: italic;"></span>. When the first condition is
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span>, DrRacket picks the right-hand side of this <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> clause:
+</div><div class="SIntrapara"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="hspace">&nbsp;</span><span class="RktSym">answer</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">condition-1</span><span class="hspace">&nbsp;</span><span class="RktSym">answer-1</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><p></p></td><td align="center" valign="mid" width="30"><p><span class="RktSym">==</span></p></td><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktSym">answer</span></p></blockquote></div><p></p></td></tr></tbody></table></div><div class="SIntrapara">We call this rule <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span style="font-style: italic;"></span><span style="vertical-align: sub; font-size: 80%;"><span style="font-style: italic;">true</span></span><span style="font-style: italic;"></span>. It also applies when the
+ condition is <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span>.</div><p></p><p></p><div class="SIntrapara">Consider the following evaluation:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._zero~3f%29%29" class="RktValLink" data-pltdoc="x">zero?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">1</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></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="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">by plain arithmetic and </span><span class="RktCmt">“</span><span class="RktCmt">equals for equals</span><span class="RktCmt">”</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">1</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></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="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">by rule </span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span style="font-style: italic;"></span><span style="vertical-align: sub; font-size: 80%;"><span style="font-style: italic;">false</span></span><span style="font-style: italic;"></span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">1</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></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="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">by plain arithmetic and </span><span class="RktCmt">“</span><span class="RktCmt">equals for equals</span><span class="RktCmt">”</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">1</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></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="RktSym">==</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">by rule </span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span><span style="font-style: italic;"></span><span style="vertical-align: sub; font-size: 80%;"><span style="font-style: italic;">true</span></span><span style="font-style: italic;"></span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">The calculation illustrates plain arithmetic, the replacement of equals by
+ equals, and the two <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> rules.</div><p></p><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3aeval1))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;111. Evaluate the following expressions step by step:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">12</span><span class="hspace">&nbsp;</span><span class="RktVal">8</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">2/3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._sqrt%29%29" class="RktValLink" data-pltdoc="x">sqrt</a></span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3e%29%29" class="RktValLink" data-pltdoc="x">&gt;</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string~3d~3f%29%29" class="RktValLink" data-pltdoc="x">string=?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="hspace">&nbsp;</span><span class="RktVal">"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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">9</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3e%29%29" class="RktValLink" data-pltdoc="x">&gt;</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string~3d~3f%29%29" class="RktValLink" data-pltdoc="x">string=?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="hspace">&nbsp;</span><span class="RktVal">"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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">9</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara"><img src="qed.png" alt=""></div><p></p></blockquote><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3aeval+def1))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;112. Suppose the program contains these definitions:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">Show how DrRacket evaluates the following expressions, step by step:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktVal">1</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">f</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</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;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">19</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara"><img src="qed.png" alt=""></div><p></p></blockquote><h4><a name="(part._sec~3asynsem~3aerrors)"></a>BSL: Errors</h4><p>When DrRacket discovers that some parenthesized phrase does not belong to
+ BSL, it signals a <span style="font-style: italic;">syntax error</span>. To determine whether a
+ fully-parenthesized program is syntactically legal, DrRacket uses the grammar
+ in <a href="#%28counter._%28figure._fig~3asyn-beginner%29%29" data-pltdoc="x">figure&nbsp;<span class="FigureRef">28</span></a> and reasons along the lines explained
+ above. Not all syntactically legal programs have meaning, however.</p><p></p><div class="SIntrapara">When DrRacket evaluates a syntactically legal program and discovers that some
+ operation is used on the wrong kind of value, it raises a
+ <span style="font-style: italic;">run-time error</span>. Consider the simple example of <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktVal">0</span><span class="RktPn">)</span>. It is a syntactically legal sentence, but you know from mathematics
+ that <span style="font-style: italic;"></span>1<span style="font-style: italic;">/</span>0<span style="font-style: italic;"></span> does not have a value. Since BSL’s calculations must be
+ consistent with mathematics, DrRacket signals an error:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">/: division by zero</span></p></td></tr><tr><td><table cellspacing="0"><tbody><tr><td></td></tr></tbody></table></td></tr></tbody></table></blockquote></div><div class="SIntrapara">Naturally it also signals an error when an expression such as <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktVal">0</span><span class="RktPn">)</span> is nested deeply inside of an another expression:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">/: division by zero</span></p></td></tr><tr><td><table cellspacing="0"><tbody><tr><td></td></tr></tbody></table></td></tr></tbody></table></blockquote></div><p></p><p></p><div class="SIntrapara">DrRacket’s behavior translates into our calculations as follows. When we find an
+ expression that is not a value and when the evaluation rules allow no further
+ simplification, we say the computation is <span style="font-style: italic;">stuck</span>. This notion of
+ stuck corresponds to a run-time error. For an example, calculating with the
+ expression from above leads to a stuck state:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">40</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">What this calculation also shows is that DrRacket eliminates the context of a
+ stuck expression as it signals an error. In this concrete example, it
+ eliminates the addition of <span class="RktVal">40</span> to the stuck expression <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktVal">0</span><span class="RktPn">)</span>.</div><p></p><p></p><div class="SIntrapara">Not all nested stuck expressions end up signaling errors. Suppose a program
+contains this definition:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">my-divide</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"inf"</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">If you now apply <span class="RktSym">my-divide</span> to <span class="RktVal">0</span>, DrRacket calculates as follows:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym">my-divide</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"inf"</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">1</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">0</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">It would obviously be wrong to say that the function signals the
+ division-by-zero error now, even though an evaluation of the shaded
+ subexpression may suggest it. The reason is that <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="stt"> </span><span class="RktVal">0</span><span class="stt"> </span><span class="RktVal">0</span><span class="RktPn">)</span> evaluates
+ to <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span> and therefore the second <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> clause does not play
+ any role:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym">my-divide</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"inf"</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">1</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">0</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"inf"</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">1</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">0</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktVal">"inf"</span></td></tr></tbody></table></blockquote></div><p></p><p></p><div class="SIntrapara">Fortunately, our laws of evaluation take care of these situations
+automatically. We just need to keep in mind when the laws apply.
+For example, in
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">the addition cannot take place before the multiplication or
+division. Similarly, the shaded division in
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">inf</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">1</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">0</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">cannot be substituted for the complete <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> expression
+until the corresponding line is the first condition in the <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span>.</div><p></p><p></p><div class="SIntrapara">As a rule of thumb, it is best to keep the following in mind:
+</div><div class="SIntrapara"><blockquote><p>Simplify the outermost and left-most subexpression that is ready for
+evaluation.</p></blockquote></div><div class="SIntrapara">While this guideline is a simplification, it always explains BSL’s results.</div><p></p><p></p><div class="SIntrapara">In some cases, programmers also want to define functions that raise errors.
+ Recall the checked version of <span class="RktSym">area-of-disk</span> from <a indepth="true" href="part_one.html#(part._sec~3ainput-errors)" data-pltdoc="x">Input Errors</a>:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checked-area-of-disk</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">area-of-disk</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"number expected"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">Now imagine applying <span class="RktSym">checked-area-of-disk</span> to a string:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checked-area-of-disk</span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checked-area-of-disk</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="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">area-of-disk</span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"number expected"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checked-area-of-disk</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="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">area-of-disk</span><span class="hspace">&nbsp;</span><span class="RktVal">"a"</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"number expected"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checked-area-of-disk</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="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._-%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"number expected"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checked-area-of-disk</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">At this point you might try to evaluate the second expression, but even if
+ you do find out that its result is roughly <span class="RktVal">314</span>, your calculation
+ must eventually deal with the <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span> expression, which is just
+ like a stuck expression. In short, the calculation ends in
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"number expected"</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><p></p><h4><a name="(part._sec~3asynsem~3aand-or)"></a>Boolean Expressions</h4><p>Our current definition of the Beginning Student BSL language omits two
+ forms of expressions: <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> and <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span> expressions.  Adding them
+ provides a case study of how to study new language constructs.  We must first
+ understand their syntax and then their semantics.</p><p></p><div class="SIntrapara">Here is the revised grammar of expressions:
+</div><div class="SIntrapara"><table cellspacing="0"><tbody><tr><td align="right" valign="baseline"><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">expr</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="RktSym">...</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">)</span></td></tr></tbody></table></div><div class="SIntrapara">The grammar says that <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> and <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span> are keywords, each
+ followed by two expressions. At first glance, the two expressions look like
+ function applications.</div><p></p><p></p><div class="SIntrapara">To understand why <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> and <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span> are not BSL-defined
+ functions, we must look at their pragmatics first.
+ Suppose we need to formulate a condition that determines whether <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktSym">n</span><span class="RktPn">)</span>
+ is <span class="RktSym">r</span>:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">check</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">We formulate the condition as an <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> combination of two Boolean
+ expressions because we don’t wish to divide by <span class="RktVal">0</span> accidentally.
+ Now let us apply <span class="RktSym">check</span> to  <span class="RktVal">0</span> and <span class="RktVal">1/5</span>:
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym">check</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">1/5</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktSym">==</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._~3d%29%29" class="RktValLink" data-pltdoc="x">=</a></span><span class="hspace">&nbsp;</span><span class="highlighted"><span class="RktPn">(</span></span><span class="highlighted"><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._htdp-beginner._%28%28lib._lang%2Fhtdp-beginner..rkt%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">1</span></span><span class="highlighted"><span class="hspace">&nbsp;</span></span><span class="highlighted"><span class="RktVal">0</span></span><span class="highlighted"><span class="RktPn">)</span></span><span class="hspace">&nbsp;</span><span class="RktVal">1/5</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><div class="SIntrapara">If <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> were an ordinary operation, we would have to evaluate
+ both subexpressions, and doing so would trigger an error.
+ Instead <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> is not a primitive operation, and its evaluation
+ throws away the second expression when the first one is <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span>. In
+ short an <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> expression short-circuits evaluation.</div><p></p><p></p><div class="SIntrapara">Now it would be easy to formulate evaluation rules for <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> and
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span>. Another way to explain their meaning is to show how to
+ translate them into equivalent expressions:
+</div><div class="SIntrapara"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktVar">exp-1</span><span class="hspace">&nbsp;</span><span class="RktVar">exp-2</span><span class="RktPn">)</span></p></blockquote></div><p></p></td><td align="center" valign="mid" width="90"><p>is short for</p></td><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktVar">exp-1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktVar">exp-2</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><p></p></td></tr></tbody></table></div><div class="SIntrapara">and
+</div><div class="SIntrapara"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="hspace">&nbsp;</span><span class="RktVar">exp-1</span><span class="hspace">&nbsp;</span><span class="RktVar">exp-2</span><span class="RktPn">)</span></p></blockquote></div><p></p></td><td align="center" valign="mid" width="90"><p>is short for</p></td><td align="center" valign="top" width="250"><p></p><div class="SIntrapara"><blockquote class="SCodeFlow"><table class="RktBlk" cellspacing="0"><tbody><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktVar">exp-1</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._else%29%29" class="RktStxLink" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktVar">exp-2</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></tbody></table></blockquote></div><p></p></td></tr></tbody></table></div><div class="SIntrapara">So if you are ever in doubt about how to evaluate an <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> or
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span> expressions, use the above equivalences to calculate. But we
+ trust that you understand these operations intuitively, and that is almost
+ always enough.</div><p></p><p></p><div class="SIntrapara">Note: you may be wondering why the above abbreviations use
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktVar">exp-2</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">on the right-hand side instead of just
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktVar">exp-2</span></p></blockquote></div><div class="SIntrapara">And indeed, if <span class="RktVar">exp-2</span> evaluates to <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span> or
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span>, writing <span class="RktVar">exp-2</span> suffices and is shorter than the
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span> expression. An expression in BSL may evaluate to all kinds
+ of values, however. If it does evaluate to something other than a
+ Boolean, <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="stt"> </span><span class="RktVar">exp-2</span><span class="stt"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._true%29%29" class="RktValLink" data-pltdoc="x">true</a></span><span class="stt"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28%28lib._lang%2Fhtdp-beginner..rkt%29._false%29%29" class="RktValLink" data-pltdoc="x">false</a></span><span class="RktPn">)</span> would signal an error while
+ <span class="RktVar">exp-2</span> would not. Since <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="stt"> </span><span class="RktVar">exp-1</span><span class="stt"> </span><span class="RktVar">exp-2</span><span class="RktPn">)</span> also signals
+ an error when <span class="RktVar">exp-2</span> evaluates to something other than a Boolean,
+ we use the above right-hand side and not the inaccurate short-cut.</div><p></p><blockquote class="SubFlow"><p></p><div class="SIntrapara"><a name="(counter._(exercise._ex~3aif-cond))"></a><span style="font-weight: bold;">Exercise</span>&nbsp;113. The use of <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span> may have surprised you in
+ another way because this intermezzo does not mention this form elsewhere.
+ In short, the intermezzo appears to explain <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span> with a form that
+ has no explanation either. At this point, we are relying on your intuitive
+ understanding of <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span> as a short-hand for <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span>. Write down
+ a rule that shows how to reformulate
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktVar">exp-test</span><span class="hspace">&nbsp;</span><span class="RktVar">exp-then</span><span class="hspace">&nbsp;</span><span class="RktVar">exp-else</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">as a <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._cond%29%29" class="RktStxLink" data-pltdoc="x">cond</a></span> expression. <img src="qed.png" alt=""></div><p></p></blockquote><h4><a name="(part._sec~3asynsem~3avar-defns~7d._)"></a>Constant Definitions</h4><p></p><div class="SIntrapara">Programs consist not only of function definitions but also constant
+definitions, but these weren’t included in our first grammar.
+So here is an extended grammar that includes constant definitions:
+</div><div class="SIntrapara"><table cellspacing="0"><tbody><tr><td align="right" valign="baseline"><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">definition</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="RktSym">...</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"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktVar">name</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">)</span></td></tr></tbody></table></div><div class="SIntrapara">The shape of a constant definition is similar to that of a function
+ definition.  It starts with a “(”, followed by the keyword
+ <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span>, followed by a variable, followed by an expression, and
+ closed by a right parenthesis “)” that matches the very first one.
+ While the keyword <span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span> distinguishes constant definitions from
+ expressions, it does not differentiate from function definitions. For
+ that, a human reader must look at the second component of the
+ definition. <span class="refelem"><span class="refcolumn"><span class="refcontent">As it turns out DrRacket has another way of dealing
+with function definitions; see <a indepth="true" href="part_three.html#(part._ch~3a3lambda)" data-pltdoc="x">Nameless Functions</a>.</span></span></span></div><p></p><p></p><div class="SIntrapara">Next we must understand what a constant definition means. For a constant
+ definition with a literal constant on the right hand side, such as
+</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">RADIUS</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">it is easy to see that the variable is just a short hand for the
+ value. Tat is, wherever DrRacket encounters <span class="RktSym">RADIU