JuliaMath / JuliaMath/IntervalSets.jl
Do we need to provide `ordered`?
- Dominant language
- Julia
- Stars
- 109
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
`Base.minmax` is almost the same, and `IntervalSets.ordered` is not used in IntervalSets.jl itself.
```julia
julia> using IntervalSets
julia> ordered(1,2)
(1, 2)
julia> minmax(1,2)
(1, 2)
julia> ordered(1.0,2)
(1.0, 2.0)
julia> minmax(1.0,2)
(1.0, 2.0)
julia> ordered("bc","ade")
("ade", "bc")
julia> minmax("bc","ade")
("ade", "bc")
```
The only differences are type promotion and if-statement.
```julia
julia> ordered([2.0], [1,3])
([1.0, 3.0], [2.0])
julia> minmax([2.0], [1,3]) # does not promote
([1, 3], [2.0])
```
`IntervalSets.ordered` uses `ifelse`.
https://github.com/JuliaMath/IntervalSets.jl/blob/master/src/IntervalSets.jl#L68
But `Base.minmax` uses ternary operator `_?_:_`
https://github.com/JuliaLang/julia/blob/8922eaa5517536eb51eb542f4543a8c6b82fda34/base/operators.jl#L514
I'm not sure which implementation is ideal, but `Base.minmax` should be fixed if `IntervalSets.ordered` wins in some aspect, and I think we don't have to provide our `ordered` function.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.