-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add a method to get the size(length) of interval instance. #42
Comments
smth like:
|
I understand that this would be a nice, simple feature to add to Also, I do not agree that |
Quoting documentation: "Note that discrete intervals are not supported by portion" so I assume the numbered intervals represent sets of real numbers, in which case, the length of an interval is defined as upper - lower, no matter if the ends are open or closed. Re subtraction being a prerequisite: I agree, it breaks the consistency, but imho the most use cases of portion will be dealing with numbers, and the benefit of having this nice function will make it worth it. |
Discrete domains are implicitly supported, but not for numbers, since we cannot (always) distinguish between floats and integers (i.e. given However, if the general definition of "length of an interval" for real numbers is the one you provided, I expect that anyone needing to compute the length of an interval will implement the corresponding function by herself on top of |
I close this issue, but I'll definitely keep the idea in mind for a potential next major release of |
e.g.
P.open(1, 2).size() == 1
P.closed(1, 2).size() == 1
(P.open(1, 2) | P.closed(4, 5)).size() == 2
The text was updated successfully, but these errors were encountered: