-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsrangesEverything AbstractRangeEverything AbstractRange
Description
Right now we have
julia> r1=range(-2, 4, step=0.5)
-2.0:0.5:4.0
julia> r2 = range(3, 9, step=0.5)
3.0:0.5:9.0
julia> r1+r2
1.0:1.0:13.0
julia> r1.+r2
1.0:1.0:13.0
But I wonder whether it would be worthwhile to make + the set addition (aka r1+r2 = {a+b | a\in r1, b\in r2})
and thus the step wouldn't change.
Implementation:
julia> function newadd(a::AbstractRange, b::AbstractRange)
step(a)==step(b) || error("have to have same step")
return range(first(a)+first(b), last(a)+last(b), step=step(a))
end
newadd (generic function with 1 method)
julia> newadd(r1,r2)
1.0:0.5:13.0 #step ist now 0.5 instead of 1.0
mbauman
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsrangesEverything AbstractRangeEverything AbstractRange