From f6055419b1cd182bfa27f103a9fa94c8392b2463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20St=C3=B6hrer?= Date: Wed, 5 Feb 2025 11:05:33 +0100 Subject: [PATCH] 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. --- xml/chapter2/section3/subsection4.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xml/chapter2/section3/subsection4.xml b/xml/chapter2/section3/subsection4.xml index ebfffc325..90b5db3a5 100644 --- a/xml/chapter2/section3/subsection4.xml +++ b/xml/chapter2/section3/subsection4.xml @@ -773,16 +773,16 @@ function make_leaf_set(pairs) { make_leaf_set_example -make_leaf_set( list( make_leaf("A", 4), - make_leaf("B", 2), - make_leaf("C", 1), - make_leaf("D", 1) ) ); +make_leaf_set( list( list("A", 4), + list("B", 2), + list("C", 1), + list("D", 1) ) ); -head(make_leaf_set( list( make_leaf("A", 4), - make_leaf("B", 2), - make_leaf("C", 1), - make_leaf("D", 1) ) ) ); +head(make_leaf_set( list( list("A", 4), + list("B", 2), + list("C", 1), + list("D", 1) ) ) );