-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
foreword-1.html
421 lines (411 loc) · 37.5 KB
/
foreword-1.html
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!doctype html>
<html lang="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Laika 1.0.0" />
<title>Foreword to the First Edition</title>
<meta name="description" content="book" />
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400|Source+Sans+Pro:300,400,600"
rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Crimson+Pro:400" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/creative-scala.css" />
<script src="js/toc.js"></script><script src="js/solution.js"></script><script src="main.js"></script>
<script> /* for avoiding page load transitions */</script>
</head>
<body>
<nav id="topbar">
<details>
<summary>Creative Scala: Form and Function</summary>
<ul class="nav-list">
<li class="level1 active nav-leaf"><a href="#">Foreword to the First Edition</a></li>
<li class="level1 nav-leaf"><a href="foreword-2.html">Foreword to the Second Edition</a></li>
<li class="level1 nav-node"><a href="setup/">Getting Started</a></li>
<li class="level2 nav-leaf"><a href="setup/background.html">Background</a></li>
<li class="level2 nav-leaf"><a href="setup/terminal.html">Our Recommended Setup</a></li>
<li class="level2 nav-leaf"><a href="setup/github.html">GitHub</a></li>
<li class="level2 nav-leaf"><a href="setup/intellij.html">IntelliJ</a></li>
<li class="level2 nav-leaf"><a href="setup/">Setup</a></li>
<li class="level1 nav-leaf"><a href="part-one-introduction.html">Part One: Introduction</a></li>
<li class="level1 nav-node"><a href="expressions/">Expressions, Values, and Types</a></li>
<li class="level2 nav-leaf"><a href="expressions/02-starting.html">Starting to Program</a></li>
<li class="level2 nav-leaf"><a href="expressions/03-expressions.html">Expressions and Values</a></li>
<li class="level2 nav-leaf"><a href="expressions/04-types.html">Types</a></li>
<li class="level2 nav-leaf"><a href="expressions/05-exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="expressions/06-conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="expanding-expressions/">Expanding Expressions</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/02-literals.html">Literal Expressions</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/03-objects.html">Values are Objects</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/04-types.html">Types</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/05-exercises.html">Exercises</a></li>
<li class="level1 nav-node"><a href="expressive-expressions/">Expressive Expressions</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/01-images.html">Images</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/02-layout.html">Layout</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/03-color.html">Color</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/04-creating-color.html">Creating Colors</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/05-exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/06-conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="programs/">Writing Larger Programs</a></li>
<li class="level2 nav-leaf"><a href="programs/names.html">Names</a></li>
<li class="level2 nav-leaf"><a href="programs/abstraction.html">Abstraction</a></li>
<li class="level2 nav-leaf"><a href="programs/outside-worksheet.html">Working Without Worksheets</a></li>
<li class="level2 nav-leaf"><a href="programs/imports.html">Packages and Imports</a></li>
<li class="level2 nav-leaf"><a href="programs/sbt.html">Using The Build System</a></li>
<li class="level2 nav-leaf"><a href="programs/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="substitution/">The Substitution Model of Evaluation</a></li>
<li class="level2 nav-leaf"><a href="substitution/substitution.html">Substitution</a></li>
<li class="level2 nav-leaf"><a href="substitution/order.html">Order of Evaluation</a></li>
<li class="level2 nav-leaf"><a href="substitution/local-reasoning.html">Local Reasoning</a></li>
<li class="level2 nav-leaf"><a href="substitution/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="methods/">Methods without Madness</a></li>
<li class="level2 nav-leaf"><a href="methods/methods.html">Methods</a></li>
<li class="level2 nav-leaf"><a href="methods/syntax.html">Method Syntax</a></li>
<li class="level2 nav-leaf"><a href="methods/semantics.html">Method Semantics</a></li>
<li class="level2 nav-leaf"><a href="methods/writing-methods.html">Writing Methods</a></li>
<li class="level2 nav-leaf"><a href="methods/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="recursion/">Structural Recursion over the Natural Numbers</a></li>
<li class="level2 nav-leaf"><a href="recursion/boxes.html">A Line of Boxes</a></li>
<li class="level2 nav-leaf"><a href="recursion/natural-numbers.html">The Natural Numbers</a></li>
<li class="level2 nav-leaf"><a href="recursion/match.html">Match Expressions</a></li>
<li class="level2 nav-leaf"><a href="recursion/substitution.html">Reasoning about Recursion</a></li>
<li class="level2 nav-leaf"><a href="recursion/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="fractals/">Fractals</a></li>
<li class="level2 nav-leaf"><a href="fractals/fractals.html">Fun with Fractals</a></li>
<li class="level2 nav-leaf"><a href="fractals/nested-methods.html">Nested Methods</a></li>
<li class="level2 nav-leaf"><a href="fractals/auxillary-parameter.html">Auxiliary Parameters</a></li>
<li class="level2 nav-leaf"><a href="fractals/exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="fractals/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="polygons/">Points, Paths, and Polygons</a></li>
<li class="level2 nav-leaf"><a href="polygons/02-polar.html">Polar Coordinates</a></li>
<li class="level2 nav-leaf"><a href="polygons/03-path.html">Paths</a></li>
<li class="level2 nav-leaf"><a href="polygons/04-creative.html">Going Further</a></li>
<li class="level2 nav-leaf"><a href="polygons/05-conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="flowers/">Functions and Flowers</a></li>
<li class="level2 nav-leaf"><a href="flowers/functions.html">Functions as Abstractions</a></li>
<li class="level2 nav-leaf"><a href="flowers/fun.html">Fun with Functions</a></li>
<li class="level2 nav-leaf"><a href="flowers/parametric-curves.html">Parametric Curves</a></li>
<li class="level2 nav-leaf"><a href="flowers/flowers.html">Flowers and Other Curves</a></li>
<li class="level2 nav-leaf"><a href="flowers/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="cycles/">Composition and Cycles</a></li>
<li class="level2 nav-leaf"><a href="cycles/composition.html">Function Composition</a></li>
<li class="level2 nav-leaf"><a href="cycles/fun.html">Fun with Composition</a></li>
<li class="level2 nav-leaf"><a href="cycles/interpolation.html">Interpolation</a></li>
<li class="level2 nav-leaf"><a href="cycles/epicycles.html">Epicycles</a></li>
<li class="level2 nav-leaf"><a href="cycles/culmination.html">Bringing it Together</a></li>
<li class="level2 nav-leaf"><a href="cycles/conclusions.html">Conclusions</a></li>
<li class="level1 nav-leaf"><a href="part-one-conclusions.html">Part One: Conclusions</a></li>
<li class="level1 nav-leaf"><a href="part-two-introduction.html">Part Two: Introduction</a></li>
<li class="level1 nav-node"><a href="2-explore/">Exploring Data Science</a></li>
<li class="level2 nav-leaf"><a href="2-explore/loading.html">Loading Data</a></li>
<li class="level2 nav-leaf"><a href="2-explore/initial.html">Initial Investigations</a></li>
<li class="level2 nav-leaf"><a href="2-explore/summarize.html">Summarizing Data</a></li>
<li class="level1 nav-node"><a href="2-loading-data/">Loading Data</a></li>
<li class="level2 nav-leaf"><a href="2-loading-data/source.html">Loading Data Using a Source</a></li>
<li class="level1 nav-header">adt</li>
<li class="level2 nav-leaf"><a href="adt/">Algebraic Data Types To Call Our Own</a></li>
<li class="level2 nav-leaf"><a href="adt/turtle.html">Build Your Own Turtle</a></li>
<li class="level2 nav-leaf"><a href="adt/adt.html">Algebraic Data Types</a></li>
<li class="level1 nav-leaf"><a href="intro.html">Introduction</a></li>
<li class="level1 nav-header">turtles</li>
<li class="level2 nav-leaf"><a href="turtles/">Turtle Algebra and Algebraic Data Types</a></li>
<li class="level2 nav-leaf"><a href="turtles/exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="turtles/turtles.html">Controlling the Turtle</a></li>
<li class="level2 nav-leaf"><a href="turtles/branching.html">Branching Structures</a></li>
<li class="level1 nav-header">sequences</li>
<li class="level2 nav-leaf"><a href="sequences/paths.html">Paths</a></li>
<li class="level2 nav-leaf"><a href="sequences/">Shapes, Sequences, and Stars</a></li>
<li class="level2 nav-leaf"><a href="sequences/lists.html">Working with Lists</a></li>
<li class="level2 nav-leaf"><a href="sequences/stars.html">My God, It's Full of Stars!</a></li>
<li class="level2 nav-leaf"><a href="sequences/map.html">Transforming Sequences</a></li>
<li class="level1 nav-leaf"><a href="links.html">links.md</a></li>
<li class="level1 nav-header">declarations</li>
<li class="level2 nav-leaf"><a href="declarations/color-palette.html">Extended Exercise: Color Palettes</a></li>
<li class="level2 nav-leaf"><a href="declarations/">Declarations</a></li>
<li class="level2 nav-leaf"><a href="declarations/method-declarations.html">Method Declarations</a></li>
<li class="level2 nav-leaf"><a href="declarations/take-home-points.html">Take Home Points</a></li>
<li class="level2 nav-leaf"><a href="declarations/value-declarations.html">Value Declarations</a></li>
<li class="level1 nav-header">animation</li>
<li class="level2 nav-leaf"><a href="animation/reactor.html">Reactors</a></li>
<li class="level2 nav-leaf"><a href="animation/">Animation and Fireworks</a></li>
<li class="level2 nav-leaf"><a href="animation/easing.html">Easing Functions</a></li>
<li class="level1 nav-header">collections</li>
<li class="level2 nav-leaf"><a href="collections/paths.html">Drawing Paths</a></li>
<li class="level2 nav-leaf"><a href="collections/">Collections {#collections}</a></li>
<li class="level2 nav-leaf"><a href="collections/transform.html">Transforming Sequences</a></li>
<li class="level2 nav-leaf"><a href="collections/take-home-points.html">Take Home Points</a></li>
<li class="level2 nav-leaf"><a href="collections/create.html">Creating Sequences</a></li>
<li class="level1 nav-header">quickreference</li>
<li class="level2 nav-leaf"><a href="quickreference/">Syntax Quick Reference {#syntax-quick-reference}</a></li>
<li class="level1 nav-header">generative</li>
<li class="level2 nav-leaf"><a href="generative/for.html">For Comprehensions</a></li>
<li class="level2 nav-leaf"><a href="generative/flatmap.html">Combining Random Values</a></li>
<li class="level2 nav-leaf"><a href="generative/">Composition of Generative Art</a></li>
<li class="level2 nav-leaf"><a href="generative/product.html">Combining Random Values</a></li>
<li class="level2 nav-leaf"><a href="generative/api.html">Exploring Random</a></li>
<li class="level2 nav-leaf"><a href="generative/random.html">Randomness without Effect</a></li>
<li class="level2 nav-leaf"><a href="generative/exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="generative/generative.html">Generative Art</a></li>
<li class="level1 nav-header">summary</li>
<li class="level2 nav-leaf"><a href="summary/">Summary</a></li>
<li class="level1 nav-header">fp</li>
<li class="level2 nav-leaf"><a href="fp/functions.html">Functions as Values</a></li>
<li class="level2 nav-leaf"><a href="fp/">(Functional) Programming</a></li>
<li class="level2 nav-leaf"><a href="fp/recursion.html">Recursive Algorithms</a></li>
<li class="level2 nav-leaf"><a href="fp/take-home-points.html">Take Home Points</a></li>
<li class="level1 nav-header">data</li>
<li class="level2 nav-leaf"><a href="data/">Creating and Working With Data</a></li>
<li class="level2 nav-leaf"><a href="data/case-classes.html">Case Classes</a></li>
<li class="level2 nav-leaf"><a href="data/data.html">Data</a></li>
<li class="level1 nav-leaf"><a href="solutions.html">Solutions to Exercises {#solutions}</a></li>
</ul>
</details>
</nav>
<nav id="sidebar">
<ul class="nav-list">
<li class="level1 nav-leaf"><a href="index.html">Creative Scala: Form and Function</a></li>
<li class="level1 active nav-leaf"><a href="#">Foreword to the First Edition</a></li>
<li class="level1 nav-leaf"><a href="foreword-2.html">Foreword to the Second Edition</a></li>
<li class="level1 nav-node"><a href="setup/">Getting Started</a></li>
<li class="level2 nav-leaf"><a href="setup/background.html">Background</a></li>
<li class="level2 nav-leaf"><a href="setup/terminal.html">Our Recommended Setup</a></li>
<li class="level2 nav-leaf"><a href="setup/github.html">GitHub</a></li>
<li class="level2 nav-leaf"><a href="setup/intellij.html">IntelliJ</a></li>
<li class="level2 nav-leaf"><a href="setup/">Setup</a></li>
<li class="level1 nav-leaf"><a href="part-one-introduction.html">Part One: Introduction</a></li>
<li class="level1 nav-node"><a href="expressions/">Expressions, Values, and Types</a></li>
<li class="level2 nav-leaf"><a href="expressions/02-starting.html">Starting to Program</a></li>
<li class="level2 nav-leaf"><a href="expressions/03-expressions.html">Expressions and Values</a></li>
<li class="level2 nav-leaf"><a href="expressions/04-types.html">Types</a></li>
<li class="level2 nav-leaf"><a href="expressions/05-exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="expressions/06-conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="expanding-expressions/">Expanding Expressions</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/02-literals.html">Literal Expressions</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/03-objects.html">Values are Objects</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/04-types.html">Types</a></li>
<li class="level2 nav-leaf"><a href="expanding-expressions/05-exercises.html">Exercises</a></li>
<li class="level1 nav-node"><a href="expressive-expressions/">Expressive Expressions</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/01-images.html">Images</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/02-layout.html">Layout</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/03-color.html">Color</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/04-creating-color.html">Creating Colors</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/05-exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="expressive-expressions/06-conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="programs/">Writing Larger Programs</a></li>
<li class="level2 nav-leaf"><a href="programs/names.html">Names</a></li>
<li class="level2 nav-leaf"><a href="programs/abstraction.html">Abstraction</a></li>
<li class="level2 nav-leaf"><a href="programs/outside-worksheet.html">Working Without Worksheets</a></li>
<li class="level2 nav-leaf"><a href="programs/imports.html">Packages and Imports</a></li>
<li class="level2 nav-leaf"><a href="programs/sbt.html">Using The Build System</a></li>
<li class="level2 nav-leaf"><a href="programs/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="substitution/">The Substitution Model of Evaluation</a></li>
<li class="level2 nav-leaf"><a href="substitution/substitution.html">Substitution</a></li>
<li class="level2 nav-leaf"><a href="substitution/order.html">Order of Evaluation</a></li>
<li class="level2 nav-leaf"><a href="substitution/local-reasoning.html">Local Reasoning</a></li>
<li class="level2 nav-leaf"><a href="substitution/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="methods/">Methods without Madness</a></li>
<li class="level2 nav-leaf"><a href="methods/methods.html">Methods</a></li>
<li class="level2 nav-leaf"><a href="methods/syntax.html">Method Syntax</a></li>
<li class="level2 nav-leaf"><a href="methods/semantics.html">Method Semantics</a></li>
<li class="level2 nav-leaf"><a href="methods/writing-methods.html">Writing Methods</a></li>
<li class="level2 nav-leaf"><a href="methods/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="recursion/">Structural Recursion over the Natural Numbers</a></li>
<li class="level2 nav-leaf"><a href="recursion/boxes.html">A Line of Boxes</a></li>
<li class="level2 nav-leaf"><a href="recursion/natural-numbers.html">The Natural Numbers</a></li>
<li class="level2 nav-leaf"><a href="recursion/match.html">Match Expressions</a></li>
<li class="level2 nav-leaf"><a href="recursion/substitution.html">Reasoning about Recursion</a></li>
<li class="level2 nav-leaf"><a href="recursion/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="fractals/">Fractals</a></li>
<li class="level2 nav-leaf"><a href="fractals/fractals.html">Fun with Fractals</a></li>
<li class="level2 nav-leaf"><a href="fractals/nested-methods.html">Nested Methods</a></li>
<li class="level2 nav-leaf"><a href="fractals/auxillary-parameter.html">Auxiliary Parameters</a></li>
<li class="level2 nav-leaf"><a href="fractals/exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="fractals/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="polygons/">Points, Paths, and Polygons</a></li>
<li class="level2 nav-leaf"><a href="polygons/02-polar.html">Polar Coordinates</a></li>
<li class="level2 nav-leaf"><a href="polygons/03-path.html">Paths</a></li>
<li class="level2 nav-leaf"><a href="polygons/04-creative.html">Going Further</a></li>
<li class="level2 nav-leaf"><a href="polygons/05-conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="flowers/">Functions and Flowers</a></li>
<li class="level2 nav-leaf"><a href="flowers/functions.html">Functions as Abstractions</a></li>
<li class="level2 nav-leaf"><a href="flowers/fun.html">Fun with Functions</a></li>
<li class="level2 nav-leaf"><a href="flowers/parametric-curves.html">Parametric Curves</a></li>
<li class="level2 nav-leaf"><a href="flowers/flowers.html">Flowers and Other Curves</a></li>
<li class="level2 nav-leaf"><a href="flowers/conclusions.html">Conclusions</a></li>
<li class="level1 nav-node"><a href="cycles/">Composition and Cycles</a></li>
<li class="level2 nav-leaf"><a href="cycles/composition.html">Function Composition</a></li>
<li class="level2 nav-leaf"><a href="cycles/fun.html">Fun with Composition</a></li>
<li class="level2 nav-leaf"><a href="cycles/interpolation.html">Interpolation</a></li>
<li class="level2 nav-leaf"><a href="cycles/epicycles.html">Epicycles</a></li>
<li class="level2 nav-leaf"><a href="cycles/culmination.html">Bringing it Together</a></li>
<li class="level2 nav-leaf"><a href="cycles/conclusions.html">Conclusions</a></li>
<li class="level1 nav-leaf"><a href="part-one-conclusions.html">Part One: Conclusions</a></li>
<li class="level1 nav-leaf"><a href="part-two-introduction.html">Part Two: Introduction</a></li>
<li class="level1 nav-node"><a href="2-explore/">Exploring Data Science</a></li>
<li class="level2 nav-leaf"><a href="2-explore/loading.html">Loading Data</a></li>
<li class="level2 nav-leaf"><a href="2-explore/initial.html">Initial Investigations</a></li>
<li class="level2 nav-leaf"><a href="2-explore/summarize.html">Summarizing Data</a></li>
<li class="level1 nav-node"><a href="2-loading-data/">Loading Data</a></li>
<li class="level2 nav-leaf"><a href="2-loading-data/source.html">Loading Data Using a Source</a></li>
<li class="level1 nav-header">adt</li>
<li class="level2 nav-leaf"><a href="adt/">Algebraic Data Types To Call Our Own</a></li>
<li class="level2 nav-leaf"><a href="adt/turtle.html">Build Your Own Turtle</a></li>
<li class="level2 nav-leaf"><a href="adt/adt.html">Algebraic Data Types</a></li>
<li class="level1 nav-leaf"><a href="intro.html">Introduction</a></li>
<li class="level1 nav-header">turtles</li>
<li class="level2 nav-leaf"><a href="turtles/">Turtle Algebra and Algebraic Data Types</a></li>
<li class="level2 nav-leaf"><a href="turtles/exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="turtles/turtles.html">Controlling the Turtle</a></li>
<li class="level2 nav-leaf"><a href="turtles/branching.html">Branching Structures</a></li>
<li class="level1 nav-header">sequences</li>
<li class="level2 nav-leaf"><a href="sequences/paths.html">Paths</a></li>
<li class="level2 nav-leaf"><a href="sequences/">Shapes, Sequences, and Stars</a></li>
<li class="level2 nav-leaf"><a href="sequences/lists.html">Working with Lists</a></li>
<li class="level2 nav-leaf"><a href="sequences/stars.html">My God, It's Full of Stars!</a></li>
<li class="level2 nav-leaf"><a href="sequences/map.html">Transforming Sequences</a></li>
<li class="level1 nav-leaf"><a href="links.html">links.md</a></li>
<li class="level1 nav-header">declarations</li>
<li class="level2 nav-leaf"><a href="declarations/color-palette.html">Extended Exercise: Color Palettes</a></li>
<li class="level2 nav-leaf"><a href="declarations/">Declarations</a></li>
<li class="level2 nav-leaf"><a href="declarations/method-declarations.html">Method Declarations</a></li>
<li class="level2 nav-leaf"><a href="declarations/take-home-points.html">Take Home Points</a></li>
<li class="level2 nav-leaf"><a href="declarations/value-declarations.html">Value Declarations</a></li>
<li class="level1 nav-header">animation</li>
<li class="level2 nav-leaf"><a href="animation/reactor.html">Reactors</a></li>
<li class="level2 nav-leaf"><a href="animation/">Animation and Fireworks</a></li>
<li class="level2 nav-leaf"><a href="animation/easing.html">Easing Functions</a></li>
<li class="level1 nav-header">collections</li>
<li class="level2 nav-leaf"><a href="collections/paths.html">Drawing Paths</a></li>
<li class="level2 nav-leaf"><a href="collections/">Collections {#collections}</a></li>
<li class="level2 nav-leaf"><a href="collections/transform.html">Transforming Sequences</a></li>
<li class="level2 nav-leaf"><a href="collections/take-home-points.html">Take Home Points</a></li>
<li class="level2 nav-leaf"><a href="collections/create.html">Creating Sequences</a></li>
<li class="level1 nav-header">quickreference</li>
<li class="level2 nav-leaf"><a href="quickreference/">Syntax Quick Reference {#syntax-quick-reference}</a></li>
<li class="level1 nav-header">generative</li>
<li class="level2 nav-leaf"><a href="generative/for.html">For Comprehensions</a></li>
<li class="level2 nav-leaf"><a href="generative/flatmap.html">Combining Random Values</a></li>
<li class="level2 nav-leaf"><a href="generative/">Composition of Generative Art</a></li>
<li class="level2 nav-leaf"><a href="generative/product.html">Combining Random Values</a></li>
<li class="level2 nav-leaf"><a href="generative/api.html">Exploring Random</a></li>
<li class="level2 nav-leaf"><a href="generative/random.html">Randomness without Effect</a></li>
<li class="level2 nav-leaf"><a href="generative/exercises.html">Exercises</a></li>
<li class="level2 nav-leaf"><a href="generative/generative.html">Generative Art</a></li>
<li class="level1 nav-header">summary</li>
<li class="level2 nav-leaf"><a href="summary/">Summary</a></li>
<li class="level1 nav-header">fp</li>
<li class="level2 nav-leaf"><a href="fp/functions.html">Functions as Values</a></li>
<li class="level2 nav-leaf"><a href="fp/">(Functional) Programming</a></li>
<li class="level2 nav-leaf"><a href="fp/recursion.html">Recursive Algorithms</a></li>
<li class="level2 nav-leaf"><a href="fp/take-home-points.html">Take Home Points</a></li>
<li class="level1 nav-header">data</li>
<li class="level2 nav-leaf"><a href="data/">Creating and Working With Data</a></li>
<li class="level2 nav-leaf"><a href="data/case-classes.html">Case Classes</a></li>
<li class="level2 nav-leaf"><a href="data/data.html">Data</a></li>
<li class="level1 nav-leaf"><a href="solutions.html">Solutions to Exercises {#solutions}</a></li>
</ul>
</nav>
<div id="content">
<main class="content">
<h1 id="foreword-to-the-first-edition" class="title">Foreword to the First Edition</h1>
<p>Creative Scala is aimed at developers who have no prior experience in Scala.
It is designed to give you a fun introduction to functional programming.
We assume you have some very basic familiarity with another programming language but little or no experience with Scala or other functional languages.</p>
<p>We have three goals with this book:</p>
<ol class="arabic">
<li>
<p>To give an introduction to functional programming so that you can calculate and reason about programs, and pick up and understand other introductory books on functional programming.</p>
</li>
<li>
<p>To teach you enough Scala that you can explore your own interests in and using Scala.</p>
</li>
<li>
<p>To present all this in a fun, gentle, and interesting way via two-dimensional computer graphics.</p>
</li>
</ol>
<p>Our motivation comes from our own experience learning programming, studying functional programming, and teaching Scala to commercial developers.</p>
<p>Firstly, we believe that functional programming is the future.
Since we're assuming you have little programming experience we won't go into the details of the differences between functional programming and object-oriented programming that you may have already experienced.
Suffice to say there are different ways to think about and write computer programs, and we've chosen the functional programming approach.</p>
<p>The reasons for choosing functional programming are more interesting.
It's common to teach programming by what we call the "bag of syntax" approach.
In this approach a programming language is taught a collection of syntactical features (variables, for loops, while loops, methods) and students are left to figure out on their own when to use each feature.
We've seen this method fail both when we were undergraduates learning programming, and as postgraduates teaching programming, as students simply have no systematic way to break down a problem and turn it into code.
The result is that many students dropped out due to the poor quality of teaching.
The students that remained tended to, like us, already have extensive programming experience.</p>
<p>Let's think back to primary school maths, specifically column addition.
This is the basic way we're taught to add up numbers when they're too big to do in our head.
So, for example, if we were adding up 266 + 385, we would line up the columns, carry the tens and so on.
Now maybe maths wasn't your favorite subject but there are some important lessons here.
The first is that we're given a systematic way to arrive at the solution.
We can <em>calculate</em> the solution once we realise this is a problem that requires column addition.
The second point is that we don't even have to understand why column addition works (though it helps) to use it.
So long as we follow the steps we'll get the correct answer.</p>
<p>The remarkable thing about functional programming is that it works like column addition.
We have recipes that are guaranteed to give us the correct answer if we follow them correctly.
We call this <em>calculating</em> a program.
This is not to say that programming is without creativity, but the challenge is to understand the structure of the problem and once we've done that the recipe we should use follows immediately.
The code itself is not the interesting part.</p>
<p>We're teaching functional programming using Scala, but not Scala itself.
Scala is a language that is in demand right now.
Scala programmers can relatively easily get jobs in a variety of industries, and this is an important motivation for learning Scala.
One of the reasons for Scala's popularity is that it straddles object-oriented programming, the old way of programming, and functional programming.
There is a lot of code written in an object-oriented style, and a lot of programmers who are used to that style.
Scala gives a gentle way from object-oriented programming to functional programming.
However this means Scala is a large language, and the interaction between the object-oriented and functional parts can be confusing.
We believe that functional programming is much more effective than object-oriented programming, and for new programmers there is no need to add the confusion of learning object-oriented techniques at the same time.
That can come later.
Therefore this book is exclusively using the functional programming parts of Scala.</p>
<p>Finally, we've chosen what we hope is a fun method to explore functional programming and Scala: computer graphics.
There are many introductions to Scala, but the majority use examples that either relate to business or mathematics.
For example, one of the first exercises in the very popular Coursera course is to implement sets via indicator functions.
We feel if you're the type of person who likes directly working with these sort of concepts you already have plenty of content available.
We want to target a different group: people who perhaps thought that maths was not for them but nonetheless have an interest or appreciation in the visual arts.
We won't lie: there is maths in this book, but we hope we manage to motivate and indeed visualise the concepts in a way that makes them less intimidating.</p>
<p>Although this book will give you the basic mental model
required to become competent with Scala,
you won't finish knowing <em>everything</em> you need to be self-sufficient.
For further advancement we recommend considering one of the many excellent
Scala textbooks out there, including our own <a href="http://underscore.io/training/courses/essential-scala">Essential Scala</a>.</p>
<p>If you are working through the exercises on your own,
we highly recommend joining our <a href="https://discord.com/invite/rRhcFbJxVG">Discord server</a>
to get help with the exercises and provide feedback on the book.</p>
<p>The text of <a href="https://github.com/underscoreio/creative-scala">Creative Scala</a> is open source,
as is the source code for the <a href="https://github.com/underscoreio/doodle">Doodle</a>
drawing library used in the exercises.
You can grab the code from our <a href="https://github.com/underscoreio">GitHub account</a>.
Contact us on Discord or by email if you would like to contribute.</p>
<p>Thanks for downloading and happy creative programming!</p>
<p>---Dave and Noel</p>
<h2 id="notes-on-the-early-access-edition" class="section">Notes on the Early Access Edition</h2>
<p><div class="callout callout-danger">
This is an <em>early access</em> release of Creative Scala.
There may be typos and other errors in the text and examples.</p>
<p>If you spot any mistakes or would like to provide feedback,
please let us know via our <a href="https://discord.com/invite/rRhcFbJxVG">Discord server</a> or by email:</p>
<ul>
<li>Dave Gurnell (<a href="mailto:dave@underscore.io"><a href="mailto:dave@underscore.io">dave@underscore.io</a></a>)</li>
</ul>
<ul>
<li>Noel Welsh (<a href="mailto:noel@underscore.io"><a href="mailto:noel@underscore.io">noel@underscore.io</a></a>)
</div></li>
</ul>
<h2 id="acknowledgements" class="section">Acknowledgements</h2>
<p>Creative Scala was written by <a href="http://twitter.com/davegurnell">Dave Gurnell</a> and <a href="http://twitter.com/noelwelsh">Noel Welsh</a>. Many thanks to <a href="http://twitter.com/d6y">Richard Dallaway</a>, <a href="http://twitter.com/jonoabroad">Jonathan Ferguson</a>, and the team at <a href="http://underscore.io">Underscore</a> for their invaluable contributions and extensive proof reading.</p>
<p>Thanks also to the many people who pointed out errors or made suggestions to improve the book: Neil Moore; Kelley Robinson, Julie Pitt, and the other ScalaBridge organizers; d43; Matt Kohl; Alexa Kovachevich and all the other students who worked through Creative Scala at ScalaBridge, at another event, or on their own; and the many awesome members of the Scala community who gave us comments and suggestions in person. Finally, we have large amount of gratitude for Bridgewater, and particularly Lauren Cipicchio, who perhaps unknowingly funded a good portion of the initial development of the second version of the Creative Scala, and provided the first few rounds of students.</p>
<p>Finally, Creative Scala owes a large intellectual debt to the work of many researchers working in programming language theory and Computer Science education. In particular we'd like to highlight:</p>
<ul>
<li>the work of the <a href="http://racket-lang.org/plt.html">PLT research group</a>, and in particular the book <a href="http://htdp.org/">"How to Design Programs"</a>, by Matthew Flatt, Matthias Felleisen, Robert Bruce Findler, and Shriram Krishnamurthi; and</li>
<li>the "creative coding" approach to introductory programming pioneered by <a href="https://www.cc.gatech.edu/faculty/mark.guzdial/">Mark Guzdial</a>, <a href="https://cs.brynmawr.edu/~dxu/">Dianna Xu</a>, and others.</li>
</ul>
<div class="flex flex-row justify-between">
<a class="pageNavigation" href="index.html">←Creative Scala: Form and Function</a> <a class="pageNavigation" href="foreword-2.html">Foreword to the Second Edition→</a>
</div>
</main>
<footer>Creative Scala is copyright Noel Welsh</footer>
</div>
</div>
</body>
</html>