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

[Stdlib] add custom starting accumulator to fold #275

Closed
LudwikJaniuk opened this issue Jun 17, 2016 · 1 comment
Closed

[Stdlib] add custom starting accumulator to fold #275

LudwikJaniuk opened this issue Jun 17, 2016 · 1 comment

Comments

@LudwikJaniuk
Copy link
Contributor

Yes, the current version of fold can sum a list of numbers (but not an empty one!). But as soon as we want to do something more complicated where the accumulator is not of the same type as the elements, or we need to tolerate an empty list with some identity value, the current fold is unusable.

I propose the you add another argument or another version of the function that would allow people to provide their own starting accumulator. See fold vs fold1 in Haskell.

@leafo
Copy link
Owner

leafo commented Sep 25, 2016

I plan to deprecate the moon module, and only include things that are specific to the MoonScript generated code (like working with class objects).

Utility methods like these are better suited to a separate module.

@leafo leafo closed this as completed Sep 25, 2016
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