-
Notifications
You must be signed in to change notification settings - Fork 96
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 open interval iterators for numbers #77
Comments
Here are the trait names Rust uses for these (they also have Syntax for ranges, but maybe the names are helpful anyway):
|
Haskell says |
And where should these live? In each integral type? |
Or can we write a generic one that takes a module (perhaps with min an max values) and does the right thing now? |
Per @nomeata's earlier suggestion, I think it's appropriate if they live in each integral type's module. As for naming, I'd keep Not sure we desperately need all the open variants. |
Should it really be |
We don't use verbs for other iterators, like keys, vals, entries -- I suppose nouns are established practice because they read more naturally with |
Currently, range has type (Nat, Int) -> Iter. The Int was introduced by @chenyan-dfinity to safely support patterns like
range(0, array.size()-1)
.Instead, we should provide variants of range and revRange that interpret the bounds as an open interval on the max end. We probably shouldn't change range itself, though, since it is too natural to (mis)interpret
range(0, 10)
as a closed interval, which could lead to bugs if it wasn't.Any ideas for a nice suggestive naming scheme for open range functions?
The text was updated successfully, but these errors were encountered: