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

Have a 'reduce' method on Array #527

Open
masak opened this issue May 30, 2019 · 0 comments
Open

Have a 'reduce' method on Array #527

masak opened this issue May 30, 2019 · 0 comments

Comments

@masak
Copy link
Owner

masak commented May 30, 2019

(Filed while staring at #176.)

I like the way it works in JavaScript. Specifically, you need to either provide an "initial value", or make sure the list is nonempty. If you do neither of those, you get an error.

That's nice because it means something like [].reduce(infix:<min>) will just outright fail. (We can't exactly return inf there because, by #517, our infinities are syntactic.)

With things like [].reduce(infix:<+>) I guess we could ask the infix:<+> nicely if it has a "zero value". But that's beyond the scope of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant