-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
foldr(-,2:2)
throws an error while foldl(-,2:2)
does not
#21107
Comments
Actually, I think it's a bug: _
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0-pre.alpha.193 (2017-03-20 02:33 UTC)
_/ |\__'_|_|_|\__'_| | Commit 28ea9d4 (0 days old master)
|__/ | x86_64-apple-darwin16.4.0
julia> reduce(-,2:2)
2
julia> foldl(-,2:2)
2
julia> foldr(-,2:2)
ERROR: BoundsError: attempt to access 1-element UnitRange{Int64} at index [0]
Stacktrace:
[1] throw_boundserror(::UnitRange{Int64}, ::Int64) at ./abstractarray.jl:426
[2] getindex at ./range.jl:464 [inlined]
[3] mapfoldr_impl(::Base.#identity, ::Base.#-, ::Int64, ::UnitRange{Int64}, ::Int64) at ./reduce.jl:110
[4] mapfoldr(::Base.#identity, ::Function, ::UnitRange{Int64}) at ./reduce.jl:139
[5] foldr(::Function, ::UnitRange{Int64}) at ./reduce.jl:166 |
dlfivefifty
changed the title
Mar 20, 2017
foldr(-,2:2)
could have better error messagefoldr(-,2:2)
throws an error while foldl(-,2:2)
does not
Note this is related to #20144 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I assume this change was intentional:
The reason behind this change makes sense, but the error message was confusing.
The text was updated successfully, but these errors were encountered: