Skip to content

Commit 9ecaee6

Browse files
committed
Add index terms to Chapter 15
1 parent 073c3f3 commit 9ecaee6

File tree

11 files changed

+622
-565
lines changed

11 files changed

+622
-565
lines changed

00_intro.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ works, it is beautiful. The art of programming is the skill of
110110
controlling complexity. The great program is subdued, made simple in
111111
its complexity.
112112

113-
(((best practices)))Many programmers believe that this complexity is
114-
best managed by using only a small set of well-understood techniques
115-
in their programs. They have composed strict rules (_“best
116-
practices”_) prescribing the form programs should have, and the more
117-
zealous among them will consider those that go outside of this little
118-
safe zone to be _bad_ programmers.
113+
(((programming style)))(((best practices)))Many programmers believe
114+
that this complexity is best managed by using only a small set of
115+
well-understood techniques in their programs. They have composed
116+
strict rules (_“best practices”_) prescribing the form programs should
117+
have, and the more zealous among them will consider those that go
118+
outside of this little safe zone to be _bad_ programmers.
119119

120120
What hostility to the richness of programming—to try to reduce it to
121121
something straightforward and predictable, to place a taboo on all the
@@ -354,9 +354,9 @@ same goes for the ((exercises)). Don't assume you understand them
354354
until you've actually written a working solution.
355355

356356
I recommend to try out your solutions to exercises in an actual
357-
JavaScript interpreter, to get immediate feedback on whether what you
358-
are doing is working or not, and, hopefully, to be tempted to
359-
experiment and go beyond the exercises.
357+
JavaScript ((interpreter)), to get immediate feedback on whether what
358+
you are doing is working or not, and, hopefully, to be tempted to
359+
((experiment)) and go beyond the exercises.
360360

361361
ifdef::html_target[]
362362

@@ -368,7 +368,7 @@ endif::html_target[]
368368
ifdef::tex_target[]
369369

370370
(((sandbox)))(((code sandbox)))(((running code)))Most of the example
371-
code in this book can be found on the book's website, at
371+
code in this book can be found on the book's ((website)), at
372372
http://eloquentjavascript.net/code[_eloquentjavascript.net/code_],
373373
which also provides an easy way to run the programs and experiment
374374
with writing your own code.

01_values.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ very small numbers, you can also use scientific notation by adding an
133133

134134
That is 2.998 × 10^8^ = 299800000.
135135

136-
(((Number type,precision of)))(((floating-point numbers)))Calculations
137-
with whole numbers (also called _((integer))s_) smaller than the
138-
aforementioned 9 quadrillion are guaranteed to always be precise.
139-
Unfortunately, calculations with fractional numbers are generally not.
140-
Just as π (pi) cannot be precisely expressed by a finite number of
141-
decimal digits, many numbers lose some precision when only 64 bits are
142-
available to store them. This is a shame, but it causes practical
143-
problems only in specific situations. The important thing is to be
144-
aware of it and treat fractional digital numbers as approximations,
145-
not as precise values.
136+
(((pi)))(((Number type,precision of)))(((floating-point
137+
numbers)))Calculations with whole numbers (also called _((integer))s_)
138+
smaller than the aforementioned 9 quadrillion are guaranteed to always
139+
be precise. Unfortunately, calculations with fractional numbers are
140+
generally not. Just as π (pi) cannot be precisely expressed by a
141+
finite number of decimal digits, many numbers lose some precision when
142+
only 64 bits are available to store them. This is a shame, but it
143+
causes practical problems only in specific situations. The important
144+
thing is to be aware of it and treat fractional digital numbers as
145+
approximations, not as precise values.
146146

147147
=== Arithmetic ===
148148

02_program_structure.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ character is written `"\n"`.
995995

996996
Use `console.log` to inspect the output of your program.
997997

998-
(((nesting,of loops)))To work with two dimensions, you will need a
998+
(((nesting,of loops)))To work with two ((dimensions)), you will need a
999999
((loop)) inside of a loop. Put ((braces)) around the bodies of both
10001000
loops to make it easy to see where they start and end. Try to properly
10011001
indent these bodies. The order of the loops must follow the order in

04_data.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ contains `cos` (cosine), `sin` (sine), and `tan` (tangent), as well as
10501050
their inverse functions, `acos`, `asin`, and `atan`. The number π
10511051
(pi)—or at least the closest approximation that fits in a JavaScript
10521052
number—is available as `Math.PI`. (There is an old programming
1053-
tradition of writing the names of constant values in all caps.)
1053+
tradition of writing the names of ((constant)) values in all caps.)
10541054

10551055
// test: no
10561056

06_object.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,15 +1069,15 @@ fit.
10691069
[[exercise_vector]]
10701070
=== A vector type ===
10711071

1072-
(((Vector type)))(((coordinates)))(((vector (exercise))))Write a
1072+
(((dimensions)))(((Vector type)))(((coordinates)))(((vector (exercise))))Write a
10731073
((constructor)) `Vector` that represents a vector in two-dimensional
10741074
space. It takes `x` and `y` parameters (numbers), which it should save
10751075
to properties of the same name.
10761076

1077-
Give the `Vector` prototype two methods, `plus` and `minus`, which
1078-
take another vector as a parameter, and return a new vector that has
1079-
the sum or difference of the two vectors’ (the one in `this` and the
1080-
parameter) x and y values.
1077+
(((addition)))(((subtraction)))Give the `Vector` prototype two
1078+
methods, `plus` and `minus`, which take another vector as a parameter,
1079+
and return a new vector that has the sum or difference of the two
1080+
vectors’ (the one in `this` and the parameter) x and y values.
10811081

10821082
Add a ((getter)) property `length` to the prototype that computes the
10831083
length of the vector—that is, the distance of the point (x, y) from

07_elife.txt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ and instead work through a program with you. Theory is indispensable
1919
when learning to program, but it should be accompanied by reading and
2020
understanding non-trivial programs.
2121

22-
(((electronic life project)))(((ecosystem)))Our project in this
23-
chapter is to build a virtual ecosystem, a little world populated with
24-
((critter))s that move around and struggle for survival.
22+
(((artificial life)))(((electronic life)))(((ecosystem)))Our
23+
project in this chapter is to build a virtual ecosystem, a little
24+
world populated with ((critter))s that move around and struggle for
25+
survival.
2526

2627
== Definition ==
2728

28-
(((electronic life project)))In order to make this task manageable, we
29-
will radically simplify the concept of a _((world))_. Namely, a world
30-
will be a two-dimensional ((grid)) where each entity takes up one full
31-
square of the grid. On every _((turn))_, the critters all get a chance
32-
to take some action.
29+
(((dimensions)))(((electronic life)))In order to make this
30+
task manageable, we will radically simplify the concept of a
31+
_((world))_. Namely, a world will be a two-dimensional ((grid)) where
32+
each entity takes up one full square of the grid. On every _((turn))_,
33+
the critters all get a chance to take some action.
3334

3435
(((discretization)))(((simulation)))Thus, we chop both time and space
3536
into units with a fixed size: squares for space and turns for time. Of
@@ -60,7 +61,7 @@ var plan =
6061
"############################"];
6162
----
6263

63-
The “#” characters in this plan represent walls and rocks, and the
64+
The “#” characters in this plan represent ((wall))s and rocks, and the
6465
“o” characters represent critters. The spaces, as you might have
6566
guessed, are empty space.
6667

@@ -172,7 +173,7 @@ console.log(grid.get(new Vector(1, 1)));
172173

173174
== A critter's programming interface ==
174175

175-
(((record)))(((electronic life project)))(((interface)))Before we can
176+
(((record)))(((electronic life)))(((interface)))Before we can
176177
start on the `World` ((constructor)), we must get more specific about
177178
the ((critter)) objects that will be living inside it. I mentioned
178179
that the world will ask the critters what actions they want to take.
@@ -263,7 +264,7 @@ when crowded into a corner by other critters).
263264

264265
== The world object ==
265266

266-
(((World type)))(((electronic life project)))Now we can start on the
267+
(((World type)))(((electronic life)))Now we can start on the
267268
`World` object type. The ((constructor)) takes a plan (the array of
268269
strings representing the world's grid, described
269270
link:07_elife.html#grid[earlier]) and a _((legend))_ as arguments. A
@@ -333,7 +334,7 @@ World.prototype.toString = function() {
333334
};
334335
----
335336

336-
(((electronic life project)))(((constructor)))(((Wall type)))A wall is
337+
(((electronic life)))(((constructor)))(((Wall type)))A ((wall)) is
337338
a very simple object—it is only used for taking up space, and has no
338339
`act` method.
339340

@@ -468,7 +469,7 @@ Grid.prototype.forEach = function(f, context) {
468469

469470
== Animating life ==
470471

471-
(((simulation)))(((electronic life project)))(((World type)))The next
472+
(((simulation)))(((electronic life)))(((World type)))The next
472473
step is to write a `turn` method for the world object that gives the
473474
((critter))s a chance to act. It will go over the grid using the
474475
`forEach` method we just defined, looking for objects with an `act`
@@ -528,7 +529,7 @@ World.prototype.checkDestination = function(action, vector) {
528529
};
529530
----
530531

531-
(((View type)))(((electronic life project)))First, we simply ask the
532+
(((View type)))(((electronic life)))First, we simply ask the
532533
critter to act, passing it a view object that knows about the world
533534
and the critter's current position in that world (we'll define `View`
534535
in a link:07_elife.html#view[moment]). The `act` method returns an
@@ -607,7 +608,7 @@ in, the critters still won't be tempted to try and walk off the edges.
607608

608609
== It moves ==
609610

610-
(((electronic life project)))(((simulation)))We instantiated a world
611+
(((electronic life)))(((simulation)))We instantiated a world
611612
object before. Now that we've added all the necessary methods, it
612613
should be possible to actually make it move.
613614

@@ -763,7 +764,7 @@ endif::html_target[]
763764

764765
== A more lifelike simulation ==
765766

766-
(((simulation)))(((electronic life project)))To make life in our world
767+
(((simulation)))(((electronic life)))To make life in our world
767768
more interesting, we will add the concepts of ((food)) and
768769
((reproduction)). Each living thing in the world gets a new property,
769770
`energy`, which is reduced by performing actions and increased by
@@ -816,7 +817,7 @@ LifelikeWorld.prototype.letAct = function(critter, vector) {
816817
};
817818
----
818819

819-
(((electronic life project)))(((function,as value)))(((call
820+
(((electronic life)))(((function,as value)))(((call
820821
method)))(((this)))The new `letAct` method first checks whether an
821822
action was returned at all, then whether a handler function for this
822823
type of action exists, and finally, whether that handler returned
@@ -917,7 +918,7 @@ actionTypes.reproduce = function(critter, vector, action) {
917918
};
918919
----
919920

920-
(((electronic life project)))Reproducing costs twice the ((energy))
921+
(((electronic life)))Reproducing costs twice the ((energy))
921922
level of the newborn critter. So we first create a (hypothetical) baby
922923
using `elementFromChar` on the critter's own origin character. Once we
923924
have a baby, we can find its energy level and test whether the parent
@@ -929,7 +930,7 @@ require a valid (and empty) destination.
929930

930931
== Populating the new world ==
931932

932-
(((Plant type)))(((electronic life project)))We now have a
933+
(((Plant type)))(((electronic life)))We now have a
933934
((framework)) to simulate these more lifelike creatures. We could put
934935
the critters from the old world into it, but they would just die,
935936
since they don't have an ((energy)) property. So let us make new ones.
@@ -987,7 +988,7 @@ creature will look for when it searches for ((food)).
987988

988989
== Bringing it to life ==
989990

990-
(((electronic life project)))And that gives us enough elements to try
991+
(((electronic life)))And that gives us enough elements to try
991992
our new world. Imagine the map below as a grassy valley with a herd of
992993
((herbivore))s in it, some boulders, and lush ((plant)) life
993994
everywhere.

08_error.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,12 @@ console.log(numberToString(13, 10));
263263
moment that you don't. We know that our program is malfunctioning, and
264264
we want to find out why.
265265

266-
This is where you must resist the urge to start making random changes
267-
to the code. Instead, _think_. Analyze what is happening and come up
268-
with a ((theory)) of why it might be happening. Then, make additional
269-
observations to test this theory—or, if you don't yet have a theory,
270-
make additional observations that might help you come up with one.
266+
(((trial-and-error)))This is where you must resist the urge to start
267+
making random changes to the code. Instead, _think_. Analyze what is
268+
happening and come up with a ((theory)) of why it might be happening.
269+
Then, make additional observations to test this theory—or, if you
270+
don't yet have a theory, make additional observations that might help
271+
you come up with one.
271272

272273
(((console.log)))(((output)))(((debugging)))(((logging)))Putting a few
273274
strategic `console.log` calls into the program is a good way to get
@@ -804,8 +805,8 @@ var box = {
804805
};
805806
----
806807

807-
(((private property)))(((access control)))It is a box, with a lock.
808-
Inside is an array, but you can only get at it when the box is
808+
(((private property)))(((access control)))It is a ((box)), with a
809+
lock. Inside is an array, but you can only get at it when the box is
809810
unlocked. Directly accessing the `_content` property is not allowed.
810811

811812
(((finally keyword)))(((exception handling)))Write a function called

09_regexp.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
[chapterquote="true"]
88
[quote,Jamie Zawinski]
99
____
10-
Some people, when confronted with a problem, think ‘I know, I'll use
11-
regular expressions.’ Now they have two problems.
10+
(((Zawinski+++,+++ Jamie)))Some people, when confronted with a
11+
problem, think ‘I know, I'll use regular expressions.’ Now they have
12+
two problems.
1213
____
1314

1415
ifdef::html_target[]
@@ -23,11 +24,11 @@ ____
2324

2425
endif::html_target[]
2526

26-
Programming tools and techniques survive and spread
27-
in a chaotic, evolutionary way. It's not always the pretty or
28-
brilliant ones that win, but rather the ones that function
29-
well enough within the right niche—for example by being
30-
integrated with another successful piece of technology.
27+
(((evolution)))Programming ((tool))s and techniques survive and spread in a chaotic,
28+
evolutionary way. It's not always the pretty or brilliant ones that
29+
win, but rather the ones that function well enough within the right
30+
niche—for example by being integrated with another successful piece of
31+
technology.
3132

3233
In this chapter I will discuss one such tool, _regular expressions_.
3334
Regular expressions are a way to describe patterns in string data.

0 commit comments

Comments
 (0)