Skip to content

Commit a79f09d

Browse files
committed
Rename some asciidoc macros to have more meaningful names
1 parent 2eb22c1 commit a79f09d

24 files changed

Lines changed: 134 additions & 134 deletions

02_program_structure.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ exercises, refer to the end of the introduction.
867867

868868
Each exercise starts with a problem description. Read that and try to
869869
solve the exercise. If you run into problems, consider reading the
870-
hints (!html after the exercise!)(!tex at the link:solutions[end of the book]!).
870+
hints (!html after the exercise!)(!book at the link:solutions[end of the book]!).
871871
Full solutions to the exercises are not included in this
872872
book, but you can find them online at
873873
http://eloquentjavascript.net/code[_eloquentjavascript.net/code_].
@@ -912,7 +912,7 @@ the exercise. Remember that you can click code blocks to edit them.
912912
----
913913
endif::html_target[]
914914

915-
!!solution!!
915+
!!hint!!
916916

917917
(((triangle (exercise))))You can start with a program that simply
918918
prints out the numbers 1 to 7, which you can derive by making a few
@@ -925,7 +925,7 @@ characters. You can go from 1 to 2 by adding 1 (`+= 1`). You can go
925925
from `"#"` to `"##"` by adding a character (`+= "#"`). Thus, your
926926
solution can closely follow the number-printing program.
927927

928-
!!solution!!
928+
!!hint!!
929929

930930
=== FizzBuzz ===
931931

@@ -949,7 +949,7 @@ ifdef::html_target[]
949949
----
950950
endif::html_target[]
951951

952-
!!solution!!
952+
!!hint!!
953953

954954
(((FizzBuzz (exercise))))(((remainder operator)))(((% operator)))Going
955955
over the numbers is clearly a looping job, and selecting what to print
@@ -967,7 +967,7 @@ For the clever method, build up a string containing the word or words
967967
to output, and print either this word or the number if there is no
968968
word, potentially by making elegant use of the `||` operator.
969969

970-
!!solution!!
970+
!!hint!!
971971

972972
=== Chess board ===
973973

@@ -1001,7 +1001,7 @@ ifdef::html_target[]
10011001
----
10021002
endif::html_target[]
10031003

1004-
!!solution!!
1004+
!!hint!!
10051005

10061006
(((chess board (exercise))))The string can be built by starting with
10071007
an empty one (`""`) and repeatedly adding characters. A newline
@@ -1026,4 +1026,4 @@ Terminating a line by adding a newline character happens after the
10261026
line has been built up, so do this after the inner loop but inside of
10271027
the outer loop.
10281028

1029-
!!solution!!
1029+
!!hint!!

03_functions.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ console.log(min(0, -10));
916916
----
917917
endif::html_target[]
918918

919-
!!solution!!
919+
!!hint!!
920920

921921
(((minimum (exercise))))If you have trouble putting braces and
922922
parentheses in the right place to get a valid function definition,
@@ -925,7 +925,7 @@ start by copying one of the examples in this chapter and modifying it.
925925
(((return keyword)))A function may contain multiple `return`
926926
statements.
927927

928-
!!solution!!
928+
!!hint!!
929929

930930
=== Recursion ===
931931

@@ -965,7 +965,7 @@ console.log(isEven(-1));
965965
----
966966
endif::html_target[]
967967

968-
!!solution!!
968+
!!hint!!
969969

970970
(((isEven (exercise))))(((if keyword,chaining)))(((recursion)))Your
971971
function will likely look somewhat similar to the inner `find`
@@ -982,7 +982,7 @@ recurse again and again, passing itself an ever more negative number,
982982
thus getting further and further away from returning a result. It will
983983
eventually run out of stack space and abort.
984984

985-
!!solution!!
985+
!!hint!!
986986

987987
=== Bean counting ===
988988

@@ -1020,7 +1020,7 @@ console.log(countChar("kakkerlak", "k"));
10201020
----
10211021
endif::html_target[]
10221022

1023-
!!solution!!
1023+
!!hint!!
10241024

10251025
(((bean counting (exercise))))(((length property,for
10261026
strings)))(((counter variable)))A ((loop)) in your function will have
@@ -1033,4 +1033,4 @@ counter can be returned.
10331033
(((local variable)))Take care to make all the variables used in the
10341034
function _local_ to the function by using the `var` keyword.
10351035

1036-
!!solution!!
1036+
!!hint!!

04_data.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -500,20 +500,20 @@ pass:[\begin{equation}\phi = \frac{n_{11}n_{00}-n_{10}n_{01}}{\sqrt{n_{1\bullet}
500500

501501
endif::tex_target[]
502502

503-
The notation (!html _n_~01~!)(!tex pass:[$n_{01}$]!) indicates the
503+
The notation (!html _n_~01~!)(!book pass:[$n_{01}$]!) indicates the
504504
number of measurements where the first measurement (pizza) is false
505505
(0) and the second measurement (squirrelness) is true (1). In this
506-
example, (!html _n_~01~!)(!tex pass:[$n_{01}$]!) is 4.
506+
example, (!html _n_~01~!)(!book pass:[$n_{01}$]!) is 4.
507507

508-
The value (!html _n_~1•~!)(!tex pass:[$n_{1\bullet}$]!) refers to the
508+
The value (!html _n_~1•~!)(!book pass:[$n_{1\bullet}$]!) refers to the
509509
sum of all measurements where the first variable is true, which is 10
510-
in the example table. Likewise, (!html _n_~•0~!)(!tex pass:[$n_{\bullet0}$]!)
510+
in the example table. Likewise, (!html _n_~•0~!)(!book pass:[$n_{\bullet0}$]!)
511511
refers to the sum of the measurements where the squirrel variable is false.
512512

513513
(((correlation)))(((phi coefficient)))So for the pizza table, the part
514514
above the division line (the dividend) would be 1×76 - 9×4 = 40, and
515515
the part below it (the divisor) would be the square root of
516-
10×80×5×85, or (!html √340000!)(!tex pass:[$\sqrt{340000}$]!). This
516+
10×80×5×85, or (!html √340000!)(!book pass:[$\sqrt{340000}$]!). This
517517
comes out to _ϕ_ ≈ 0.069, which is tiny. Eating ((pizza)) does not
518518
appear to have influence on the transformations.
519519

@@ -557,13 +557,13 @@ console.log(phi([76, 9, 4, 1]));
557557
translation of the _ϕ_ formula into JavaScript. `Math.sqrt` is the
558558
square root function, as provided by the `Math` object in a standard
559559
JavaScript environment. We have to sum two fields from the table to
560-
get fields like (!html n~1•~!)(!tex pass:[$n_{1\bullet}$]!) because
560+
get fields like (!html n~1•~!)(!book pass:[$n_{1\bullet}$]!) because
561561
the sums of rows or columns are not stored directly in our data
562562
structure.
563563

564564
(((JOURNAL data set)))Jacques kept his journal for three months. The
565565
resulting ((data set)) is available in the coding sandbox for this
566-
chapter(!tex (http://eloquentjavascript.net/code[_eloquentjavascript.net/code_])!),
566+
chapter(!book (http://eloquentjavascript.net/code[_eloquentjavascript.net/code_])!),
567567
where it is stored in the `JOURNAL` variable, and in a downloadable
568568
http://eloquentjavascript.net/code/jacques_journal.js[file].
569569

@@ -1206,7 +1206,7 @@ console.log(range(5, 2, -1));
12061206
----
12071207
endif::html_target[]
12081208

1209-
!!solution!!
1209+
!!hint!!
12101210

12111211
(((summing (exercise))))(((array,creation)))(((square
12121212
brackets)))Building up an array is most easily done by first
@@ -1234,7 +1234,7 @@ It might also be worthwhile to use a different default step, namely,
12341234
`range(5, 2)` returns something meaningful, rather than getting stuck
12351235
in an ((infinite loop)).
12361236

1237-
!!solution!!
1237+
!!hint!!
12381238

12391239
=== Reversing an array ===
12401240

@@ -1271,7 +1271,7 @@ console.log(arrayValue);
12711271
----
12721272
endif::html_target[]
12731273

1274-
!!solution!!
1274+
!!hint!!
12751275

12761276
(((reversing (exercise))))There are two obvious ways to implement
12771277
`reverseArray`. The first is to simply go over the input array from
@@ -1296,7 +1296,7 @@ briefly hold on to one of the elements, overwrite that one with its
12961296
mirror image, and then put the value from the local variable in the
12971297
place where the mirror image used to be.
12981298

1299-
!!solution!!
1299+
!!hint!!
13001300

13011301
=== A list ===
13021302

@@ -1366,7 +1366,7 @@ console.log(nth(arrayToList([10, 20, 30]), 1));
13661366
----
13671367
endif::html_target[]
13681368

1369-
!!solution!!
1369+
!!hint!!
13701370

13711371
(((list (exercise))))(((linked list)))Building up a list is best done
13721372
back to front. So `arrayToList` could iterate over the array backward
@@ -1397,7 +1397,7 @@ zeroeth element of a list, you simply take the `value` property of its
13971397
head node. To get element _N_ + 1, you take the __N__th element of the
13981398
list that's in this list's `rest` property.
13991399

1400-
!!solution!!
1400+
!!hint!!
14011401

14021402
[[exercise_deep_compare]]
14031403
=== Deep comparison ===
@@ -1437,7 +1437,7 @@ console.log(deepEqual(obj, {here: {is: "an"}, object: 2}));
14371437
----
14381438
endif::html_target[]
14391439

1440-
!!solution!!
1440+
!!hint!!
14411441

14421442
(((deep comparison (exercise))))(((typeof operator)))(((object)))(((=== operator)))Your test for whether you are dealing with a
14431443
real object will look something like `typeof x == "object" && x !=
@@ -1458,4 +1458,4 @@ of the properties are compared by a recursive call to `deepEqual`.
14581458
best done by immediately returning false when a mismatch is noticed
14591459
and returning true at the end of the function.
14601460

1461-
!!solution!!
1461+
!!hint!!

05_higher_order.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ console.log(JSON.parse(string).born);
431431
(((ANCESTRY_FILE data set)))The variable `ANCESTRY_FILE`, available in
432432
the ((sandbox)) for this chapter as well as in
433433
http://eloquentjavascript.net/code/ancestry.js[a downloadable file] on
434-
the website(!tex (_eloquentjavascript.net/code_)!), contains the
434+
the website(!book (_eloquentjavascript.net/code_)!), contains the
435435
content of my ((JSON)) file as a string. Let's decode it and see how
436436
many people it contains:
437437

@@ -972,7 +972,7 @@ ancestry.forEach(function(person) {
972972
----
973973
endif::html_target[]
974974

975-
!!solution!!
975+
!!hint!!
976976

977977
(((age difference (exercise))))(((filter method)))(((map
978978
method)))(((null)))(((average function)))Because not all elements in
@@ -985,7 +985,7 @@ filtering on that first. Alternatively, you could start by calling
985985
or `null` if no mother is known. Then, you can call `filter` to remove
986986
the `null` elements before passing the array to `average`.
987987

988-
!!solution!!
988+
!!hint!!
989989

990990
=== Historical life expectancy ===
991991

@@ -1021,7 +1021,7 @@ function average(array) {
10211021
----
10221022
endif::html_target[]
10231023

1024-
!!solution!!
1024+
!!hint!!
10251025

10261026
(((life expectancy (exercise))))The essence of this example lies in
10271027
((grouping)) the elements of a collection by some aspect of
@@ -1039,7 +1039,7 @@ the person (or age) to the array for the proper century.
10391039
(((for/in loop)))(((average function)))Finally, a `for`/`in` loop can
10401040
be used to print the average ages for the individual centuries.
10411041

1042-
!!solution!!
1042+
!!hint!!
10431043

10441044
(((grouping)))(((map)))(((object,as map)))(((groupBy function)))For
10451045
bonus points, write a function `groupBy` that abstracts the grouping
@@ -1085,7 +1085,7 @@ console.log(some([2, 3, 4], isNaN));
10851085
----
10861086
endif::html_target[]
10871087

1088-
!!solution!!
1088+
!!hint!!
10891089

10901090
(((every and some (exercise))))(((short-circuit evaluation)))(((return
10911091
keyword)))The functions can follow a similar pattern to the
@@ -1096,4 +1096,4 @@ Don't forget to put another `return` statement after the loop, so that
10961096
the function also returns the correct value when it reaches the end of
10971097
the array.
10981098

1099-
!!solution!!
1099+
!!hint!!

06_object.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ code doesn't really do anything interesting.
755755
mountains that we are trying to build is available in the `MOUNTAINS`
756756
variable in the ((sandbox)) and also
757757
http://eloquentjavascript.net/code/mountains.js[downloadable] from the
758-
list of data sets on the website(!tex (http://eloquentjavascript.net/code[_eloquentjavascript.net/code_])!).
758+
list of data sets on the website(!book (http://eloquentjavascript.net/code[_eloquentjavascript.net/code_])!).
759759

760760
(((table example)))We will want to highlight the top row, which
761761
contains the column names, by underlining the cells with a series of
@@ -1095,7 +1095,7 @@ console.log(new Vector(3, 4).length);
10951095
----
10961096
endif::html_target[]
10971097

1098-
!!solution!!
1098+
!!hint!!
10991099

11001100
(((vector (exercise))))Your solution can follow the pattern of the
11011101
`Rabbit` constructor from this chapter quite closely.
@@ -1106,11 +1106,11 @@ constructor can be done with the `Object.defineProperty` function. To
11061106
compute the distance from (0, 0) to (x, y), you can use the
11071107
Pythagorean theorem, which says that the square of the distance we are
11081108
looking for is equal to the square of the x coordinate plus the square
1109-
of the y coordinate. Thus, (!html √(x^2^ + y^2^)!)(!tex pass:[$\sqrt{x^2 + y^2}$]!)
1109+
of the y coordinate. Thus, (!html √(x^2^ + y^2^)!)(!book pass:[$\sqrt{x^2 + y^2}$]!)
11101110
is the number you want, and `Math.sqrt` is the way you compute a square
11111111
root in JavaScript.
11121112

1113-
!!solution!!
1113+
!!hint!!
11141114

11151115
=== Another cell ===
11161116

@@ -1141,7 +1141,7 @@ console.log(sc.draw(3, 2));
11411141

11421142
endif::html_target[]
11431143

1144-
!!solution!!
1144+
!!hint!!
11451145

11461146
(((StretchCell (exercise))))You'll have to store all three constructor
11471147
arguments in the instance object. The `minWidth` and `minHeight`
@@ -1152,7 +1152,7 @@ returned (possibly using `Math.max`).
11521152
Don't forget to add a `draw` method that simply forwards the call to
11531153
the inner cell.
11541154

1155-
!!solution!!
1155+
!!hint!!
11561156

11571157
=== Sequence interface ===
11581158

@@ -1195,7 +1195,7 @@ logFive(new RangeSeq(100, 1000));
11951195

11961196
endif::html_target[]
11971197

1198-
!!solution!!
1198+
!!hint!!
11991199

12001200
(((sequence (exercise))))(((collection)))One way to solve this is to
12011201
give the sequence objects _((state))_, meaning their properties are
@@ -1222,4 +1222,4 @@ unfortunately, also somewhat inefficient in a language like
12221222
JavaScript because it involves creating a lot of objects during
12231223
iteration.
12241224

1225-
!!solution!!
1225+
!!hint!!

07_elife.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ var valley = new LifelikeWorld(
10151015
----
10161016

10171017
(((animation)))(((simulation)))Let's see what happens if we run this.
1018-
(!tex These snapshots illustrate a typical run of this world.!)
1018+
(!book These snapshots illustrate a typical run of this world.!)
10191019

10201020
ifdef::html_target[]
10211021

@@ -1138,7 +1138,7 @@ animateWorld(new LifelikeWorld(
11381138

11391139
endif::html_target[]
11401140

1141-
!!solution!!
1141+
!!hint!!
11421142

11431143
(((artificial stupidity (exercise))))(((artificial
11441144
intelligence)))(((behavior)))(((state)))The greediness problem can be
@@ -1164,7 +1164,7 @@ more boring. If you have a handful of fat, immobile critters forever
11641164
munching on a sea of plants and never reproducing, that makes for a
11651165
very stable ecosystem. But no one wants to watch that.
11661166

1167-
!!solution!!
1167+
!!hint!!
11681168

11691169
=== Predators ===
11701170

@@ -1217,7 +1217,7 @@ animateWorld(new LifelikeWorld(
12171217

12181218
endif::html_target[]
12191219

1220-
!!solution!!
1220+
!!hint!!
12211221

12221222
(((predators (exercise))))(((reproduction)))(((starvation)))Many of
12231223
the same tricks that worked for the previous exercise also apply here.
@@ -1235,4 +1235,4 @@ starve. But you could keep track of observations in previous turns, in
12351235
some ((data structure)) kept on the predator objects, and have it base
12361236
its ((behavior)) on what it has seen recently.
12371237

1238-
!!solution!!
1238+
!!hint!!

0 commit comments

Comments
 (0)