-
Notifications
You must be signed in to change notification settings - Fork 361
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
Closed Ranges and Range Interface #138
Comments
I think there are a few things that should change:
|
From the Contracts section:
|
@Wasabi375 Well by that standard, I think indicators on @LouisCAD Fair enough, but aren't those Progressions? That might be a separate KEEP but useful nonetheless. 10.0 downTo 1.0 step .5 I could have used that in my temperature schedule for the TSP. That needs to be planned carefully though. For instance, how do we handle a |
@thomasnield No, following the standard terminology used in mathematics an open interval does not include either of its end points while a closed interval includes both of them. Than there is a half open interval which only includes one endpoint. |
As to the inclusivity indicators: I think adding will be no cost at all. They will just be a readonly property which all implementations override to either return |
@Wasabi375 Or I'd like to see use cases for And let's keep in mind, just because supporting start exclusivity is mathematically correct, it does not mean it will have use cases in a generalized programming language. I'm not sure what to do with the inclusivity indicators. I feel they add clutter and I can't think of use cases for them. Whenever you implement your own |
I think with adding
When dealing with pricing models I had to use both start and end inclusive ranges. As far as I remember startInclusive was more common than endInclusive but it was more equal than you might expect. I guess open ranges can be useful in validation and testing of calculations. As for the inclusivity indicator, I was thinking about a custom range, where the inclusivity could be changed by the user, but I think this goes beyond this KEEP, so let's forget about it. |
With your pricing model example, you mean exclusive start ranges right? Also, I posted this on MathExchange. |
Yes, I mean I had to use both ranges, which included the start and not the end, and ranges, which included the end and not the start. Imagine your histogram example just with the lower bound excluded and the upper bound included. |
I'll update the proposal and present all the approaches we discussed. I think we need to support start exclusivity after your input. Good talk. |
Proposal has been updated. The new types I documented are:
@Wasabi375 I added you as a contributor, thanks for your helpful considerations and advisement. |
Please consider taking some inspiration from Guava's Range class: https://github.com/google/guava/wiki/RangesExplained It has worked very nicely in my projects so far. |
@HaasJona I think we are pretty aligned with Guava, other than Kotlin-izing it a little. I think I'm going to create a separate KEEP for continous progressions, like |
@thomasnield I think this proposal needs a similar API review analyses of other languages and frameworks. For example, how Python and other "math" languages handle this, what are the pros and cons of their implementations. Also, Guava seems to have similar APIs, why not include their analyses, as well as their usages and possibly discovered pain points. |
@voddan done. Gave mention to Python, R, and Google Guava. |
Stumbling upon this after looking at |
Is there such a KEEP already? I work with Kotlin and 2D / 3D graphics and such progressions would often simplify my code. |
I'm considering creating a If I don't get around to this and it may be of any inspiration, I simply had a base generic As type parameters it takes both
In an old blog post of mine I elaborate a bit more, including this example code snippet to get a feel for the API:
|
I started work on this in this repository. Going smoothly so far. 🥳 |
With the planned introduction of |
This issue is for conversation regarding the proposal for Exclusive Ranges and a Range Interface.
Pull Requestion: #137
The text was updated successfully, but these errors were encountered: