Skip to content

Fix make_leaf_set function call argument #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

TomSoerr
Copy link
Contributor

@TomSoerr TomSoerr commented Feb 5, 2025

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.

See https://sourceacademy.org/sicpjs/2.3.4#p15

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.
Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct. The example is wrong and this fix is right. Tx!

@RichDom2185 RichDom2185 enabled auto-merge (squash) February 20, 2025 02:52
@RichDom2185 RichDom2185 merged commit 6e2c814 into source-academy:master Feb 20, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants