Skip to content
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

[2nd edition] Signature of foldLeft is inconsistent in answers and exercises module #609

Open
tPl0ch opened this issue Sep 12, 2021 · 1 comment

Comments

@tPl0ch
Copy link

tPl0ch commented Sep 12, 2021

In the preview text of the 2nd edition the signatures of foldLeft and foldRight are consistent, but not in the git repository exercises module (the answers module is correct).

exercises module:
def foldLeft[A,B](l: List[A], z: B)(f: (B, A) => B): B = ???

answers module:
def foldLeft[A,B](l: List[A], z: B, f: (B, A) => B): B = ...

This raises the question should Scala's auto-curry feature be explained here? Currying has been covered in the previous chapter, so this would be a good oportunity to introduce that concept. This could also be applied to other HOFsin the 3rd chapter, i.e. filter or dropWhile.

@tPl0ch tPl0ch changed the title [2nd edition] Signatures of foldLeft and foldRight are inconsistent in answers and exercises module [2nd edition] Signature of foldLeft is inconsistent in answers and exercises module Sep 12, 2021
@mpilquist
Copy link
Contributor

Thanks for spotting, I'll address shortly. There's a footnote that talks about the tradeoffs between the two signatures and how the tradeoff changes with Scala 3 type inference.

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

No branches or pull requests

2 participants