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

Do we need to provide ordered? #185

Open
hyrodium opened this issue Feb 10, 2024 · 0 comments
Open

Do we need to provide ordered? #185

hyrodium opened this issue Feb 10, 2024 · 0 comments

Comments

@hyrodium
Copy link
Collaborator

Base.minmax is almost the same, and IntervalSets.ordered is not used in IntervalSets.jl itself.

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> 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.

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

No branches or pull requests

1 participant