We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is a callback to #10391
julia> versioninfo() Julia Version 1.1.0 Commit 80516ca202 (2019-01-21 21:24 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-6.0.1 (ORCJIT, skylake) julia> a=1:1:5 1:1:5 julia> a[2:end] .- a[1:end-1] ERROR: ArgumentError: step cannot be zero Stacktrace: [1] steprange_last(::Int64, ::Int64, ::Int64) at ./range.jl:209 [2] _rangestyle at ./range.jl:199 [inlined] [3] _range at ./range.jl:110 [inlined] [4] #range#31 at ./range.jl:87 [inlined] [5] #range at ./none:0 [inlined] [6] - at ./range.jl:1006 [inlined] [7] broadcasted at ./broadcast.jl:988 [inlined] [8] broadcasted(::Function, ::StepRange{Int64,Int64}, ::StepRange{Int64,Int64}) at ./broadcast.jl:1167 [9] top-level scope at none:0 julia> a[2] - a[1] 1
Is there a reason we can't implement something like
import Base.- function -( x :: UnitRange , y :: UnitRange ) length(x) != length(y) && throw(DimensionMismatch) return StepRangeLen(x.start-y.start, 0, length(x)) end function -( x :: StepRange , y :: StepRange ) length(x) != length(y) && throw(DimensionMismatch) if x.step == y.step return StepRangeLen(x.start-y.start, 0, length(x)) else return (x.start-y.start):(x.step-y.step):(x.stop-y.stop) end end
Also this seems related to
julia> range(1,step=0,length=10) ERROR: ArgumentError: step cannot be zero Stacktrace: [1] steprange_last(::Int64, ::Int64, ::Int64) at ./range.jl:209 [2] Type at ./range.jl:199 [inlined] [3] _rangestyle at ./range.jl:112 [inlined] [4] _range at ./range.jl:110 [inlined] [5] #range#31 at ./range.jl:87 [inlined] [6] (::getfield(Base, Symbol("#kw##range")))(::NamedTuple{(:step, :length),Tuple{Int64,Int64}}, ::typeof(range), ::Int64) at ./none:0 [7] top-level scope at none:0 julia> range(1.0,step=0,length=10) 1.0:0.0:1.0
which could also be promoted to a StepRangeLen type.
StepRangeLen
The text was updated successfully, but these errors were encountered:
Let's keep all the discussion on this issue in #10391. Feel free to post this proposal there.
Sorry, something went wrong.
No branches or pull requests
This is a callback to #10391
Is there a reason we can't implement something like
Also this seems related to
which could also be promoted to a
StepRangeLen
type.The text was updated successfully, but these errors were encountered: