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

Phase out intersect(::AbstractInterval, ::AbstractInterval) -> AbstractInterval #189

Open
omus opened this issue May 16, 2022 · 1 comment
Milestone

Comments

@omus
Copy link
Collaborator

omus commented May 16, 2022

A single interval can be treated as a representation of a set. For the function intersect we added a method such that the intersection of any two intervals can return an instance of an interval. This is possible as the result of such an intersection will either be an interval or an empty interval.

However, the other set functions cannot work this way as there exist cases where multiple intervals would have to be returned:

  • union(::Interval, ::Interval) -> Interval: returns multiple intervals for disjoint intervals
  • setdiff(::Interval, ::Interval) -> Interval: return multiple intervals when the first argument is a superset of the second
  • symdiff(::Interval, ::Interval) -> Interval: returns multiple intervals in all cases except for when the intervals are contiguous

I would suggest that we use a different name for the existing intersect method and have all of the set methods return a vector so they have consistent return arguments. This is more inline with the Base behaviour.

@omus
Copy link
Collaborator Author

omus commented May 16, 2022

I came to this realization while reviewing #179

@rofinn rofinn added this to the Intervals 2.0 milestone Apr 4, 2023
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

2 participants