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

Added explanation and example for undefined associativity in reduce #5086

Merged
merged 1 commit into from
Dec 10, 2013

Conversation

ivarne
Copy link
Sponsor Member

@ivarne ivarne commented Dec 10, 2013

Some issues has been raised about how reduce works, and what undefined associativity means. This change improves the documentation in my opinion, but there is always a question about style.

The associativity of the reduction is implementation-dependent. This means
that you can't use non associative operations like ``-`` because it is
undefined whether ``reduce(-,[1,2,3])`` should be evaluated as ``(1-2)-3``
or ``1-(2-3)``. This is because errors tend to accumulate, and it is often
Copy link
Member

Choose a reason for hiding this comment

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

Also: implementations might use parallel evaluation, a data structure might be traversed fastest one way or the other, etc. You might also cross-reference to foldl and foldr here.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I don't believe that we have foldl or foldr yet.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Consider it a note for the future then.

@pao
Copy link
Member

pao commented Dec 10, 2013

Pulling this now, but could probably use a polish step.

pao added a commit that referenced this pull request Dec 10, 2013
Added explanation and example for undefined associativity in reduce
@pao pao merged commit bec5ee3 into JuliaLang:master Dec 10, 2013
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