This file is indexed.

/usr/share/doc/racket/quick/index.html is in racket-doc 6.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!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>Quick: An Introduction to Racket with Pictures</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="" class="tocviewselflink" data-pltdoc="x">Quick:<span class="mywbr"> &nbsp;</span> An Introduction to Racket with Pictures</a></td></tr></table></div><div class="tocviewsublistonly" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="#%28part._.Ready___%29" class="tocviewlink" data-pltdoc="x">Ready...</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="#%28part._.Set___%29" class="tocviewlink" data-pltdoc="x">Set...</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="#%28part._.Go_%29" class="tocviewlink" data-pltdoc="x">Go!</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="#%28part._.Definitions%29" class="tocviewlink" data-pltdoc="x">Definitions</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="#%28part._.Local_.Binding%29" class="tocviewlink" data-pltdoc="x">Local Binding</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="#%28part._.Functions_are_.Values%29" class="tocviewlink" data-pltdoc="x">Functions are Values</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="#%28part._.Lexical_.Scope%29" class="tocviewlink" data-pltdoc="x">Lexical Scope</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="#%28part._.Lists%29" class="tocviewlink" data-pltdoc="x">Lists</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="#%28part._.Modules%29" class="tocviewlink" data-pltdoc="x">Modules</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="#%28part._.Macros%29" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="#%28part._.Objects%29" class="tocviewlink" data-pltdoc="x">Objects</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="#%28part._.Where_to_.Go_.From_.Here%29" class="tocviewlink" data-pltdoc="x">Where to Go From Here</a></td></tr></table></div></div></div><div class="tocsub"><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber"></span><a href="#%28part._top%29" class="tocsubseclink" data-pltdoc="x">Quick:<span class="mywbr"> &nbsp;</span> An Introduction to Racket with Pictures</a></td></tr><tr><td><span class="tocsublinknumber">1<tt>&nbsp;</tt></span><a href="#%28part._.Ready___%29" class="tocsubseclink" data-pltdoc="x">Ready...</a></td></tr><tr><td><span class="tocsublinknumber">2<tt>&nbsp;</tt></span><a href="#%28part._.Set___%29" class="tocsubseclink" data-pltdoc="x">Set...</a></td></tr><tr><td><span class="tocsublinknumber">3<tt>&nbsp;</tt></span><a href="#%28part._.Go_%29" class="tocsubseclink" data-pltdoc="x">Go!</a></td></tr><tr><td><span class="tocsublinknumber">4<tt>&nbsp;</tt></span><a href="#%28part._.Definitions%29" class="tocsubseclink" data-pltdoc="x">Definitions</a></td></tr><tr><td><span class="tocsublinknumber">5<tt>&nbsp;</tt></span><a href="#%28part._.Local_.Binding%29" class="tocsubseclink" data-pltdoc="x">Local Binding</a></td></tr><tr><td><span class="tocsublinknumber">6<tt>&nbsp;</tt></span><a href="#%28part._.Functions_are_.Values%29" class="tocsubseclink" data-pltdoc="x">Functions are Values</a></td></tr><tr><td><span class="tocsublinknumber">7<tt>&nbsp;</tt></span><a href="#%28part._.Lexical_.Scope%29" class="tocsubseclink" data-pltdoc="x">Lexical Scope</a></td></tr><tr><td><span class="tocsublinknumber">8<tt>&nbsp;</tt></span><a href="#%28part._.Lists%29" class="tocsubseclink" data-pltdoc="x">Lists</a></td></tr><tr><td><span class="tocsublinknumber">9<tt>&nbsp;</tt></span><a href="#%28part._.Modules%29" class="tocsubseclink" data-pltdoc="x">Modules</a></td></tr><tr><td><span class="tocsublinknumber">10<tt>&nbsp;</tt></span><a href="#%28part._.Macros%29" class="tocsubseclink" data-pltdoc="x">Macros</a></td></tr><tr><td><span class="tocsublinknumber">11<tt>&nbsp;</tt></span><a href="#%28part._.Objects%29" class="tocsubseclink" data-pltdoc="x">Objects</a></td></tr><tr><td><span class="tocsublinknumber">12<tt>&nbsp;</tt></span><a href="#%28part._.Where_to_.Go_.From_.Here%29" class="tocsubseclink" data-pltdoc="x">Where to Go From Here</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.1</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<span class="nonavigation">&larr; prev</span>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">up</a>&nbsp;&nbsp;<span class="nonavigation">next &rarr;</span></span>&nbsp;</div><h2 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;top&quot;"><a name="(part._top)"></a><a name="(part._.Quick__.An_.Introduction_to_.Racket_with_.Pictures)"></a>Quick: An Introduction to Racket with Pictures</h2><div class="SAuthorListBox"><span class="SAuthorList"><p class="author">Matthew Flatt</p></span></div><p>This tutorial provides a brief introduction to the Racket
programming language by using one of its picture-drawing
libraries. Even if you don&rsquo;t intend to use Racket for your artistic
endeavours, the picture library supports interesting and enlightening
examples. After all, a picture is worth five hundred &ldquo;hello world&rdquo;s.</p><p>Along the same lines, we assume that you will run the examples using
<a href="http://racket-lang.org/">DrRacket</a>. Using DrRacket is the fastest
way to get a sense of what the language and system feels like, even if
you eventually use Racket with Emacs, vi, or some other editor.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Ready___&quot;">1<tt>&nbsp;</tt><a name="(part._.Ready___)"></a>Ready...</h3><p><a href="http://racket-lang.org/">Download Racket</a>, install, and then
start DrRacket.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Set___&quot;">2<tt>&nbsp;</tt><a name="(part._.Set___)"></a>Set...</h3><p><div class="SIntrapara"><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>See <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?tag=%28part._%28.%27%28lib._scribblings%2Fdrracket%2Fdrracket..scrbl%29.%27._.%27interface-essentials.%27%29%29&amp;version=6.1" class="Sq" data-pltdoc="x">the DrRacket documentation</a>
                   for a brief overview of
                   the DrRacket IDE.</p></blockquote></blockquote></blockquote></div><div class="SIntrapara">To draw pictures, we must first load some picture functions, which are
part of a library for creating slide presentations.  Copy the
following into the <span style="font-style: italic">definitions area</span>, which is the top text
area that you see in DrRacket:</div></p><blockquote class="SCodeFlow"><p><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&amp;rel=Module_Syntax.html%23%2528part._hash-lang%2529&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktMod">#lang</span></a><span class="hspace">&nbsp;</span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=slideshow&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">slideshow</span></a></p></blockquote><p>Then click the <span class="ssansserif">Run</span> button. You&rsquo;ll see the text caret move
to the bottom text area, which is the <span style="font-style: italic">interactions area</span>.</p><p>If you&rsquo;ve used DrRacket before, you might need to reset DrRacket to
use the language declared in the source via the <span class="ssansserif">Language|Choose Language...</span> menu item before clicking <span class="ssansserif">Run</span>.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Go_&quot;">3<tt>&nbsp;</tt><a name="(part._.Go_)"></a>Go!</h3><p>When you type an expression after the <span class="ssansserif">&gt;</span> in the interactions
window and hit Enter, DrRacket evaluates the expression and prints its
result. An expression can be just a value, such as the number
<span class="RktVal">5</span> or the string <span class="RktVal">"art gallery"</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktVal">5</span></td></tr><tr><td><p><span class="RktRes">5</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktVal">"art gallery"</span></td></tr><tr><td><p><span class="RktRes">"art gallery"</span></p></td></tr></table></blockquote><p>An expression can also be a function call. To call a function, put
an open parenthesis before the function name, then expressions for the
function arguments, and then a close parenthesis, like this:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict.png" alt="image" width="16" height="16"/></p></td></tr></table></blockquote><p>A result from the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> function is a picture value, which
prints as an expression result in much the same way that numbers or
strings print.  The argument to <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> determines the
circle&rsquo;s size in pixels.  As you might guess, there&rsquo;s a
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._rectangle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">rectangle</a></span> function that takes two arguments instead of one:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._rectangle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">rectangle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_2.png" alt="image" width="16" height="26"/></p></td></tr></table></blockquote><p>Try giving <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> the wrong number of arguments, just to see
what happens:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">circle: arity mismatch;</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr">the expected number of arguments does not match the given</span></p></td></tr><tr><td><p><span class="RktErr">number</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: 1</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: 2</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">arguments...:</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">10</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">20</span></p></td></tr></table></blockquote><p>Note that DrRacket highlights in pink the expression that triggered
the error (but pink highlighting is not shown in this documentation).</p><p>In addition to basic picture constructors like <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> and
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._rectangle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">rectangle</a></span>, there&rsquo;s a <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span> function that
combines pictures. When you start composing function calls in Racket,
it looks like this:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._rectangle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">rectangle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_3.png" alt="image" width="26" height="26"/></p></td></tr></table></blockquote><p>The hyphen in the name <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span> is just a part of the
identifier; it&rsquo;s not <span class="RktSym">hc</span> minus
<span class="RktSym">append</span>. The function name starts with <span class="RktSym">h</span>
because it combines pictures horizontally, and the next letter is
<span class="RktSym">c</span> because the pictures are centered vertically.</p><p>If you wonder what other functions exist&#8212;<wbr></wbr>perhaps a way to stack
pictures vertically and left-aligned?&#8212;<wbr></wbr>move the text caret to the
name <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span> and press the F1 key in DrRacket. A browser
window will open, and it will give you a link to the documentation for
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span>. Click the link, and you&rsquo;ll see lots of other
functions.</p><p>If you&rsquo;re reading this in HTML form, you can also just click on
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span> or any other imported identifier that is used in
this tutorial.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Definitions&quot;">4<tt>&nbsp;</tt><a name="(part._.Definitions)"></a>Definitions</h3><p>To use a particular circle and rectangle picture many times, it&rsquo;s
simpler to give them names. Move back to the definitions area (the top
area) and add two definitions, so that the complete content of the
definitions area looks like this:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&amp;rel=Module_Syntax.html%23%2528part._hash-lang%2529&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktMod">#lang</span></a><span class="hspace">&nbsp;</span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=slideshow&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">slideshow</span></a></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></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="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._rectangle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">rectangle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>Then click <span class="ssansserif">Run</span> again. Now, you can just type <span class="RktSym">c</span> or
<span class="RktSym">r</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktSym">r</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_4.png" alt="image" width="16" height="26"/></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_5.png" alt="image" width="26" height="26"/></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_6.png" alt="image" width="76" height="26"/></p></td></tr></table></blockquote><p>As you can see, the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span> function accepts an optional
number argument before the picture arguments, and it accepts any
number of picture arguments. When a number is provided, it specifies
the amount of space to add between pictures.</p><p>We could have evaluated the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> forms for <span class="RktSym">c</span> and
<span class="RktSym">r</span> in the interactions area instead of the definitions
area. In practice, though, the definitions area is where your program
lives&#8212;<wbr></wbr>it&rsquo;s the file that you save&#8212;<wbr></wbr>while the interaction area is
for transient explorations and debugging tasks.</p><p>Let&rsquo;s add a function definition to the program. A function definition
uses <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span>, just like our shape definitions, but with an
open parenthesis before the function name, and names for the function
arguments before the matching close parenthesis:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</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="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">A semi-colon starts a line comment.</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">The expression below is the function body.</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._filled-rectangle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">filled-rectangle</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>The syntax of the definition mirrors the syntax of a function
call:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_7.png" alt="image" width="16" height="16"/></p></td></tr></table></blockquote><p>In the same way that definitions can be evaluated in the interactions
area, expressions can be included in the definitions area. When a
program is run, expression results from the definition area are shown
in the interaction area. From now on, we&rsquo;ll write our example
definitions and expressions together, and you can put them in
whichever area you prefer. The examples will build on each other,
however, so it&rsquo;s best to put at least the definitions in the
definition area.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Local_Binding&quot;">5<tt>&nbsp;</tt><a name="(part._.Local_.Binding)"></a>Local Binding</h3><p>The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> form can be used in some places to create local
bindings. For example, it can be used inside a function body:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">four</span><span class="hspace">&nbsp;</span><span class="RktSym">p</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">two-p</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktSym">p</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span><span class="hspace">&nbsp;</span><span class="RktSym">two-p</span><span class="hspace">&nbsp;</span><span class="RktSym">two-p</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">four</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_8.png" alt="image" width="26" height="26"/></p></td></tr></table></td></tr></table></blockquote><p>More typically, Racketeers use the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span> or <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span> form
for local binding. An advantage of <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span> is that it can be used
in any expression position. Also, it binds many identifiers at once,
instead of requiring a separate <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> for each identifier:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checker</span><span class="hspace">&nbsp;</span><span class="RktSym">p1</span><span class="hspace">&nbsp;</span><span class="RktSym">p2</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">p12</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p1</span><span class="hspace">&nbsp;</span><span class="RktSym">p2</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">p21</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p2</span><span class="hspace">&nbsp;</span><span class="RktSym">p1</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"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p12</span><span class="hspace">&nbsp;</span><span class="RktSym">p21</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">checker</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"red"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"black"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_9.png" alt="image" width="26" height="26"/></p></td></tr></table></td></tr></table></blockquote><p>A <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span> form binds many identifiers at the same time, so the
bindings cannot refer to each other. The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span> form, in
contrast, allows later bindings to use earlier bindings:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checkerboard</span><span class="hspace">&nbsp;</span><span class="RktSym">p</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">rp</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktVal">"red"</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">bp</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktVal">"black"</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checker</span><span class="hspace">&nbsp;</span><span class="RktSym">rp</span><span class="hspace">&nbsp;</span><span class="RktSym">bp</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">c4</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">four</span><span class="hspace">&nbsp;</span><span class="RktSym">c</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">four</span><span class="hspace">&nbsp;</span><span class="RktSym">c4</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">checkerboard</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_10.png" alt="image" width="86" height="86"/></p></td></tr></table></td></tr></table></blockquote><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Functions_are_Values&quot;">6<tt>&nbsp;</tt><a name="(part._.Functions_are_.Values)"></a>Functions are Values</h3><p>Instead of calling <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> as a function, try evaluating just
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> as an expression:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span></td></tr><tr><td><p><span class="RktRes">#&lt;procedure:circle&gt;</span></p></td></tr></table></blockquote><p>That is, the identifier <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span> is bound to a function
(a.k.a. &ldquo;procedure&rdquo;), just like <span class="RktSym">c</span> is bound to a
circle. Unlike a circle picture, there&rsquo;s not a simple way of
completely printing the function, so DrRacket just prints
<span class="RktRes">#&lt;procedure:circle&gt;</span>.</p><p>This example shows that functions are values, just like numbers and
pictures (even if they don&rsquo;t print as nicely). Since functions are
values, you can define functions that expect other functions as
arguments:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktSym">mk</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_11.png" alt="image" width="49" height="26"/></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktSym">square</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_12.png" alt="image" width="49" height="26"/></p></td></tr></table></td></tr></table></blockquote><p>When calling a function that accepts a function argument, the
argument function often isn&rsquo;t needed anywhere else. Having to write
down the function via <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> would be a hassle, because you
have to make up a name and find a place to put the function
definition. The alternative is to use <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span>, which creates an
anonymous function:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">size</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">checkerboard</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktSym">size</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_13.png" alt="image" width="294" height="166"/></p></td></tr></table></blockquote><p>The parenthesized names after a <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span> are the arguments to
the function, and the expression after the argument names is the
function body. Using the word &ldquo;lambda&rdquo; instead of &ldquo;function&rdquo; or
&ldquo;procedure&rdquo; is part of Racket&rsquo;s history and culture.</p><p>A <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> form for a function is really a shorthand for a
simple <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> using <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span> as the value. For
example, the <span class="RktSym">series</span> definition could be written as</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">series</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktVal">20</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>Most Racketeers prefer to use the shorthand function form with
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span> instead of expanding to <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span>.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Lexical_Scope&quot;">7<tt>&nbsp;</tt><a name="(part._.Lexical_.Scope)"></a>Lexical Scope</h3><p>Racket is a lexically scoped language, which means that whenever an
identifier is used as an expression, something in the textual
environment of the expression determines the identifier&rsquo;s
binding. This rule applies to identifiers in a <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span> body as
well as anywhere else.</p><p>In the following <span class="RktSym">rgb-series</span> function, the uses
of <span class="RktSym">mk</span> in each <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span> form refer to the argument of
<span class="RktSym">rgb-series</span>, since that&rsquo;s the binding that is textually in
scope:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rgb-series</span><span class="hspace">&nbsp;</span><span class="RktSym">mk</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"red"</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">series</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"green"</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">series</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"blue"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">rgb-series</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_14.png" alt="image" width="49" height="66"/></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">rgb-series</span><span class="hspace">&nbsp;</span><span class="RktSym">square</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_15.png" alt="image" width="49" height="66"/></p></td></tr></table></td></tr></table></blockquote><p>Here&rsquo;s another example, where <span class="RktSym">rgb-maker</span> takes a function and
returns a new one that remembers and uses the original function.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rgb-maker</span><span class="hspace">&nbsp;</span><span class="RktSym">mk</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">sz</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"red"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"green"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mk</span><span class="hspace">&nbsp;</span><span class="RktSym">sz</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"blue"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rgb-maker</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_16.png" alt="image" width="49" height="66"/></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">series</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rgb-maker</span><span class="hspace">&nbsp;</span><span class="RktSym">square</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_17.png" alt="image" width="49" height="66"/></p></td></tr></table></td></tr></table></blockquote><p>Note how composing functions via <span class="RktSym">rgb-maker</span> creates a
different alignment of objects within the picture compared to using
<span class="RktSym">rgb-series</span>.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Lists&quot;">8<tt>&nbsp;</tt><a name="(part._.Lists)"></a>Lists</h3><p>Racket inherits much of its style from the language Lisp, whose name
originally stood for &ldquo;LISt Processor,&rdquo; and lists remain an important
part of Racket.</p><p>The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span> function takes any number of arguments and returns
a list containing the given values:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"red"</span><span class="hspace">&nbsp;</span><span class="RktVal">"green"</span><span class="hspace">&nbsp;</span><span class="RktVal">"blue"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'("red" "green" "blue")</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(</span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_18.png" alt="image" width="16" height="16"/><span class="RktRes"></span><span class="hspace">&nbsp;</span><span class="RktRes"></span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_19.png" alt="image" width="16" height="16"/><span class="RktRes">)</span></p></td></tr></table></blockquote><p>As you can see, a list prints as a single quote and then pair of parentheses wrapped around
the printed form of the list elements. There&rsquo;s room for confusion
here, because parentheses are used for both expressions, such as
<span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="RktPn">)</span>, and printed results, such as
<span class="RktRes">'("red"<span class="stt"> </span>"green"<span class="stt"> </span>"blue")</span>. The quote is the key difference,
as <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&amp;rel=Pairs__Lists__and_Racket_Syntax.html%23%2528part._quoting-lists%2529&amp;version=6.1" class="Sq" data-pltdoc="x">discussed
elsewhere</a>. To help emphasize the difference, in the documentation and in DrRacket,
result parentheses are printed in blue, unlike expression parentheses.</p><p>If you have a list, then you&rsquo;ll eventually want to do something with
each of the elements. The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmap..rkt%2529._map%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">map</a></span> function takes a list and a
function to apply to each element of the list; it returns a new list
to combine the function&rsquo;s results:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rainbow</span><span class="hspace">&nbsp;</span><span class="RktSym">p</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmap..rkt%2529._map%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">map</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">color</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktSym">color</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"red"</span><span class="hspace">&nbsp;</span><span class="RktVal">"orange"</span><span class="hspace">&nbsp;</span><span class="RktVal">"yellow"</span><span class="hspace">&nbsp;</span><span class="RktVal">"green"</span><span class="hspace">&nbsp;</span><span class="RktVal">"blue"</span><span class="hspace">&nbsp;</span><span class="RktVal">"purple"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">rainbow</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(</span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_20.png" alt="image" width="11" height="11"/><span class="RktRes"></span><span class="hspace">&nbsp;</span><span class="RktRes"></span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_21.png" alt="image" width="11" height="11"/><span class="RktRes"></span><span class="hspace">&nbsp;</span><span class="RktRes"></span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_22.png" alt="image" width="11" height="11"/><span class="RktRes"></span><span class="hspace">&nbsp;</span><span class="RktRes"></span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_23.png" alt="image" width="11" height="11"/><span class="RktRes"></span><span class="hspace">&nbsp;</span><span class="RktRes"></span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_24.png" alt="image" width="11" height="11"/><span class="RktRes"></span><span class="hspace">&nbsp;</span><span class="RktRes"></span><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_25.png" alt="image" width="11" height="11"/><span class="RktRes">)</span></p></td></tr></table></td></tr></table></blockquote><p>Another function that works with lists is <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._apply%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">apply</a></span>. Like
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmap..rkt%2529._map%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">map</a></span>, it takes a function and a list, but a function given
to <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._apply%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">apply</a></span> should take all of the arguments at once, instead of
each one individually. The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._apply%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">apply</a></span> function is especially
useful with functions that take any number of arguments, such as
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._apply%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">apply</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rainbow</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_26.png" alt="image" width="11" height="36"/></p></td></tr></table></blockquote><p>Note that <span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">rainbow</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">square</span><span class="stt"> </span><span class="RktVal">5</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span> would not work,
because <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._vc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">vc-append</a></span> does not want a list as an argument; it
wants a picture as an argument, and it is willing to accept any number
of them. The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._apply%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">apply</a></span> function bridges the gap between a
function that wants many arguments and a list of those arguments as a
single value.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Modules&quot;">9<tt>&nbsp;</tt><a name="(part._.Modules)"></a>Modules</h3><p>Since your program in the definitions window starts with</p><blockquote class="SCodeFlow"><p><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&amp;rel=Module_Syntax.html%23%2528part._hash-lang%2529&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktMod">#lang</span></a><span class="hspace">&nbsp;</span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=slideshow&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">slideshow</span></a></p></blockquote><p>all of the code that you put in the definitions window is inside a
module. Furthermore, the module initially imports everything from the
module designated by <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=slideshow&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">slideshow</span></a>, which exports
picture-making functions as well as more commonly used functions
such as <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span> and <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmap..rkt%2529._map%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">map</a></span>.</p><p>To import additional libraries, use the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span> form. For
example, the library <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528mod-path._pict%252Fflash%2529&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">pict/flash</span></a> provides a
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fflash..rkt%2529._filled-flash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">filled-flash</a></span> function:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace">&nbsp;</span><span class="RktSym">pict/flash</span><span class="RktPn">)</span></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fflash..rkt%2529._filled-flash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">filled-flash</a></span><span class="hspace">&nbsp;</span><span class="RktVal">40</span><span class="hspace">&nbsp;</span><span class="RktVal">30</span><span class="RktPn">)</span></td></tr><tr><td><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict_27.png" alt="image" width="46.0" height="34.53169548885461"/></p></td></tr></table></td></tr></table></blockquote><p>Modules are named and distributed in various ways:</p><ul><li><p>Some modules are packaged in the Racket distribution or
otherwise installed into a hierarchy of
<span style="font-style: italic">collections</span>. For example, the module name
<a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528mod-path._pict%252Fflash%2529&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">pict/flash</span></a> means &ldquo;the module implemented
in the file <span class="stt">"flash.rkt"</span> that is located in the
<span class="stt">"pict"</span> collection.&rdquo; When a module name includes
no slash, then it refers to a <span class="stt">"main.rkt"</span> file.</p></li><li><p>Some modules are distributed through the
<a href="http://planet.racket-lang.org/"><span class="planetName">PLaneT</span></a> server, and they can be
downloaded automatically on demand. For example, the first time
that you evaluate the following fragment:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._planet%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">planet</a></span><span class="hspace">&nbsp;</span><span class="RktSym">schematics/random:1:0/random</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">random-gaussian</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">0.7386912134436788</span></p></td></tr></table></td></tr></table></blockquote><p>DrRacket automatically downloads version 1.0 of the
<span class="stt">"random.plt"</span> library by <span class="stt">"schematics"</span> and then
imports the <span class="stt">"random.rkt"</span> module.</p></li><li><p><div class="SIntrapara"><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>To save your definitions, use DrRacket&rsquo;s
<a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?tag=%28part._%28.%27%28lib._scribblings%2Fdrracket%2Fdrracket..scrbl%29.%27._.%27menu%7E3afile.%27%29%29&amp;version=6.1" class="Sq" data-pltdoc="x"><span class="ssansserif">Save Definitions</span></a>
menu item.</p></blockquote></blockquote></blockquote></div><div class="SIntrapara">Some modules live relative to other modules, without
necessarily belonging to any particular collection or package.
For example, in DrRacket, if you save your definitions so far in a
file <span class="stt">"quick.rkt"</span> and add the line</div></p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._provide%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">provide</a></span><span class="hspace">&nbsp;</span><span class="RktSym">rainbow</span><span class="hspace">&nbsp;</span><span class="RktSym">square</span><span class="RktPn">)</span></p></blockquote><p>then you can open a new tab or window in DrRacket, type the new
program <span class="stt">"use.rkt"</span> in the same directory as
<span class="stt">"quick.rkt"</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&amp;rel=Module_Syntax.html%23%2528part._hash-lang%2529&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktMod">#lang</span></a><span class="hspace">&nbsp;</span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket</span></a></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"quick.rkt"</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym">rainbow</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>and when you run <span class="stt">"use.rkt"</span>, a rainbow list of squares
 is the output. Note that <span class="stt">"use.rkt"</span> is written using
 the initial import <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket</span></a>, which does not
 supply any picture-making functions itself&#8212;<wbr></wbr>but does provide
 <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span> and the function-calling syntax.</p></li></ul><p>Racketeers typically write new programs and libraries as modules that
import each other through relative paths, and that use existing
libraries from collections and <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._planet%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">planet</a></span>. When a program or
library developed this way seems useful to others, it can be uploaded
as a <span class="planetName">PLaneT</span> package or distributed in the more old-fashioned way as
an installable collection archive (in either case without modifying
the internal relative references among modules).</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Macros&quot;">10<tt>&nbsp;</tt><a name="(part._.Macros)"></a>Macros</h3><p>Here&rsquo;s another library to try:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace">&nbsp;</span><span class="RktSym">slideshow/code</span><span class="RktPn">)</span></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes"><img src="img0.png" alt="[image]" width="209" height="37"/></span></p></td></tr></table></td></tr></table></blockquote><p>Instead of a circle, the result is a picture of the code that, if it
were used as an expression, would produce a circle. In other words,
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span> is not a function, but instead a new syntactic form for
creating pictures; the bit between the opening parenthesis with
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span> is not an expression, but instead manipulated by the
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span> syntactic form.</p><p>This helps explain what we meant in the previous section when we said
that <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket</span></a> provides <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span> and the
function-calling syntax. Libraries are not restricted to exporting
values, such as functions; they can also define new syntactic
forms. In this sense, Racket isn&rsquo;t exactly a language at all; it&rsquo;s
more of an idea for how to structure a language so that you can extend
it or create entirely new languages.</p><p>One way to introduce a new syntactic form is through
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-syntax%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define-syntax</a></span> with <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._syntax-rules%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">syntax-rules</a></span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-syntax%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktSym">pict+code</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._syntax-rules%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">syntax-rules</a></span><span class="hspace">&nbsp;</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="RktPn">(</span><span class="RktSym">pict+code</span><span class="hspace">&nbsp;</span><span class="RktSym">expr</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">expr</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span><span class="hspace">&nbsp;</span><span class="RktSym">expr</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">pict+code</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes"><img src="img1.png" alt="[image]" width="229" height="37"/></span></p></td></tr></table></td></tr></table></blockquote><p>This kind of definition is a macro. The <span class="RktPn">(</span><span class="RktSym">pict+code</span><span class="stt"> </span><span class="RktSym">expr</span><span class="RktPn">)</span> part
is a pattern for uses of the macro; instances of the pattern in a
program are replaced by instances of the corresponding template, which
is <span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="stt"> </span><span class="RktSym">expr</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span><span class="stt"> </span><span class="RktSym">expr</span><span class="RktPn">)</span><span class="RktPn">)</span>.  In particular,
<span class="RktPn">(</span><span class="RktSym">pict+code</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span> matches the pattern with
<span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="RktPn">)</span> as <span class="RktSym">expr</span>, so it is replaced with
<span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Combiners.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._hc-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hc-append</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></span><span class="stt"> </span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span>.</p><p>Of course, this sort of syntactic extension cuts both ways: inventing
a new language can make it easier to say what you want, but harder for
others to understand. As it happens, the developers of Racket are
constantly giving talks and writing papers that involve Racket code,
and it&rsquo;s worthwhile for everyone who works on those products to know
about <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528form._%2528%2528lib._pict%252Fcode..rkt%2529._code%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">code</a></span>.</p><p>In fact, you might want to take a look at the 
<a href="quick.scrbl">source of this document</a>. You&rsquo;ll see that it
starts with <span class="stt">#lang</span>, but otherwise doesn&rsquo;t look a lot
like Racket; nevertheless, we build this document by running its
source as a Racket program. We have to use a lot more than
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._syntax-rules%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">syntax-rules</a></span> to extend Racket&rsquo;s syntax enough for writing
documents, but Racket&rsquo;s syntactic extension can take you a long way.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Objects&quot;">11<tt>&nbsp;</tt><a name="(part._.Objects)"></a>Objects</h3><p>An object system is another example of a sophisticated language
extension that is worth learning and using for Racket users. Objects
are sometimes better than functions, even when you have
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span>, and objects work especially well for graphical user
interfaces. The API for Racket&rsquo;s GUI and graphics system is expressed
in terms of objects and classes.</p><p>The class system itself is implemented by the
<a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=mzlib_class.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/class</span></a> library, and the
<a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=gui&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/gui/base</span></a> library provides the GUI and drawing
classes. By convention, the classes are given names that end with
<span class="RktSym">%</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace">&nbsp;</span><span class="RktSym">racket/class</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">racket/gui/base</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=objcreation.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fclass-internal..rkt%2529._new%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">new</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=gui&amp;rel=frame_.html&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">frame%</a></span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">label</span><span class="hspace">&nbsp;</span><span class="RktVal">"My Art"</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">width</span><span class="hspace">&nbsp;</span><span class="RktVal">300</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">height</span><span class="hspace">&nbsp;</span><span class="RktVal">300</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">alignment</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">center</span><span class="hspace">&nbsp;</span><span class="RktVal">center</span><span class="RktVal">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=ivaraccess.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fclass-internal..rkt%2529._send%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">send</a></span><span class="hspace">&nbsp;</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">show</span><span class="hspace">&nbsp;</span><span class="RktVal">#t</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote><p>The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=objcreation.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fclass-internal..rkt%2529._new%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">new</a></span> form creates an instance of a class, where
initialization arguments like <span class="RktSym">label</span> and <span class="RktSym">width</span> are
provided by name. The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=ivaraccess.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fclass-internal..rkt%2529._send%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">send</a></span> form calls a method of the object,
such as <span class="RktSym">show</span>, with arguments after the method name; the
argument <span class="RktVal">#t</span> in this case is the boolean constant &ldquo;true.&rdquo;</p><p>Pictures generated with <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=slideshow&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">slideshow</span></a> encapsulate a
function that uses the graphics toolbox&rsquo;s drawing commands to render
the picture to a drawing context, such as a canvas in a frame. The
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Rendering.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._make-pict-drawer%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">make-pict-drawer</a></span> function from <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=slideshow&amp;rel=index.html&amp;version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">slideshow</span></a>
exposes a picture&rsquo;s drawing function. We can use
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Rendering.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._make-pict-drawer%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">make-pict-drawer</a></span> in a canvas-painting callback to draw a
picture into a canvas:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">add-drawing</span><span class="hspace">&nbsp;</span><span class="RktSym">p</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">drawer</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Rendering.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._make-pict-drawer%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">make-pict-drawer</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p</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"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=objcreation.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fclass-internal..rkt%2529._new%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">new</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=gui&amp;rel=canvas_.html&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">canvas%</a></span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">parent</span><span class="hspace">&nbsp;</span><span class="RktSym">f</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">style</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">border</span><span class="RktVal">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">paint-callback</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">self</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._dc%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">dc</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">drawer</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._dc%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">dc</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="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">add-drawing</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">pict+code</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Basic_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._circle%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">circle</a></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="RktRes">#(struct:object:canvas% ...)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">add-drawing</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=Pict_Drawing_Adjusters.html%23%2528def._%2528%2528lib._pict%252Fmain..rkt%2529._colorize%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">colorize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=pict&amp;rel=More_Pict_Constructors.html%23%2528def._%2528%2528lib._pict%252Fflash..rkt%2529._filled-flash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">filled-flash</a></span><span class="hspace">&nbsp;</span><span class="RktVal">50</span><span class="hspace">&nbsp;</span><span class="RktVal">30</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"yellow"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#(struct:object:canvas% ...)</span></p></td></tr></table></td></tr></table></blockquote><blockquote class="SCentered"><p><span class="RktRes"><img src="img2.png" alt="[image]" width="164" height="165"/></span></p></blockquote><p>Each canvas stretches to fill an equal portion of the frame, because
that&rsquo;s how a frame manages its children by default.</p><h3 x-source-module="(lib &quot;scribblings/quick/quick.scrbl&quot;)" x-part-tag="&quot;Where_to_Go_From_Here&quot;">12<tt>&nbsp;</tt><a name="(part._.Where_to_.Go_.From_.Here)"></a>Where to Go From Here</h3><p>This introduction to Racket purposely avoids many of the
traditional ways of introducing and distinguishing Lisp or Scheme:
prefix arithmetic notation, symbols, quoting and quasiquoting lists,
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=eval.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._eval%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">eval</a></span>, first-class continuations, and the idea that all syntax
is really just a <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span> in disguise. While those are all part
of Racket, they are not the main ingredients of day-to-day programming
in Racket.</p><p>Instead, Racket programmers typically program with functions,
records, objects, exceptions, regular expressions, modules, and
threads. That is, instead of a &ldquo;minimalist&rdquo; language&#8212;<wbr></wbr>which is the
way that Scheme is often described&#8212;<wbr></wbr>Racket offers a rich language
with an extensive set of libraries and tools.</p><p>If you are new to programming or if you have the patience to work
through a textbook, we recommend reading
<span style="font-style: italic"><a href="http://www.htdp.org/">How to Design Programs</a></span>. If you
have already read it, or if you want to see where the book will take
you, then see <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=continue&amp;rel=index.html&amp;version=6.1" class="Sq" data-pltdoc="x">Continue: Web Applications in Racket</a>.</p><p>For experienced programmers, to continue touring Racket from a
systems-oriented perspective instead of pictures, your next stop is
<a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=more&amp;rel=index.html&amp;version=6.1" class="Sq" data-pltdoc="x">More: Systems Programming with Racket</a>.</p><p>To instead start learning about the full Racket language and tools
in depth, move on to <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&amp;rel=index.html&amp;version=6.1" class="Sq" data-pltdoc="x"><span style="font-weight: bold">The Racket Guide</span></a>.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<span class="nonavigation">&larr; prev</span>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">up</a>&nbsp;&nbsp;<span class="nonavigation">next &rarr;</span></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>