Skip to content

Commit 6e2c814

Browse files
authored
Fix make_leaf_set function call argument (#1076)
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 2390a6e commit 6e2c814

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
@@ -766,16 +766,16 @@ function make_leaf_set(pairs) {
766766
<SNIPPET HIDE="yes">
767767
<NAME>make_leaf_set_example</NAME>
768768
<JAVASCRIPT>
769-
make_leaf_set( list( make_leaf("A", 4),
770-
make_leaf("B", 2),
771-
make_leaf("C", 1),
772-
make_leaf("D", 1) ) );
769+
make_leaf_set( list( list("A", 4),
770+
list("B", 2),
771+
list("C", 1),
772+
list("D", 1) ) );
773773
</JAVASCRIPT>
774774
<JAVASCRIPT_TEST>
775-
head(make_leaf_set( list( make_leaf("A", 4),
776-
make_leaf("B", 2),
777-
make_leaf("C", 1),
778-
make_leaf("D", 1) ) ) );
775+
head(make_leaf_set( list( list("A", 4),
776+
list("B", 2),
777+
list("C", 1),
778+
list("D", 1) ) ) );
779779
</JAVASCRIPT_TEST>
780780
</SNIPPET>
781781
</TEXT>

0 commit comments

Comments
 (0)