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

allow arrays into the arithmetic macros #348

Merged
merged 1 commit into from Jun 20, 2017
Merged

Conversation

kellyselden
Copy link
Owner

Closes #341.

cc @mwpastore

@kellyselden
Copy link
Owner Author

What should the return value be if the array is empty?

@Fed03
Copy link
Contributor

Fed03 commented Jun 15, 2017

erroring? What happens if the array contains something that's not a number?

@mwpastore
Copy link

mwpastore commented Jun 15, 2017

That's an interesting question. I think you could probably get away with returning zero, but returning NaN might be more "correct."

@kellyselden
Copy link
Owner Author

What happens if the array contains something that's not a number?

@Fed03 It would try to add it 😛

@Fed03
Copy link
Contributor

Fed03 commented Jun 16, 2017

@Fed03 It would try to add it 😛

In that case, I think that NaN would be the right thing to return when array is empty, like suggested by @mwpastore

@kellyselden
Copy link
Owner Author

I ended up saying empty array is zero. I thought it would be easier to reason this:

total: sum('array')

vs

total: or(sum('total'), 0) or total: conditional('total.length', sum('total'), 0)

@kellyselden kellyselden merged commit de48c1c into master Jun 20, 2017
@kellyselden kellyselden deleted the array-arithmetic branch June 20, 2017 16:46
@kellyselden
Copy link
Owner Author

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.

None yet

3 participants