Skip to content

Commit f605541

Browse files
authored
Fix make_leaf_set function call argument
make_leaf_set (in line 776) "takes a list of symbol-frequency pairs such as list(list("A", 4), list("B", 2), list("C", 1), list("D", 1))" and not a list of leafs. Because the argument is a list of leafs, the resulting list will look like this: [ ["leaf", ["leaf", ["A", null]]], [ ["leaf", ["leaf", ["B", null]]], [["leaf", ["leaf", ["C", null]]], [["leaf", ["leaf", ["D", null]]], null]]]] head(first_pair) (in line 766) expects a list with the first item being the symbol and the second item the frequency.
1 parent 781eebb commit f605541

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

xml/chapter2/section3/subsection4.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -773,16 +773,16 @@ function make_leaf_set(pairs) {
773773
<SNIPPET HIDE="yes">
774774
<NAME>make_leaf_set_example</NAME>
775775
<JAVASCRIPT>
776-
make_leaf_set( list( make_leaf("A", 4),
777-
make_leaf("B", 2),
778-
make_leaf("C", 1),
779-
make_leaf("D", 1) ) );
776+
make_leaf_set( list( list("A", 4),
777+
list("B", 2),
778+
list("C", 1),
779+
list("D", 1) ) );
780780
</JAVASCRIPT>
781781
<JAVASCRIPT_TEST>
782-
head(make_leaf_set( list( make_leaf("A", 4),
783-
make_leaf("B", 2),
784-
make_leaf("C", 1),
785-
make_leaf("D", 1) ) ) );
782+
head(make_leaf_set( list( list("A", 4),
783+
list("B", 2),
784+
list("C", 1),
785+
list("D", 1) ) ) );
786786
</JAVASCRIPT_TEST>
787787
</SNIPPET>
788788
</TEXT>

0 commit comments

Comments
 (0)