number ranges
Salih Dincer
salihdb at hotmail.com
Mon Jan 17 12:47:20 UTC 2022
On Monday, 17 January 2022 at 11:58:18 UTC, Paul Backus wrote:
> On Monday, 17 January 2022 at 10:24:06 UTC, forkit wrote:
> Edsger W. Dijkstra, a well-known academic computer scientist,
> has written in more detail about the advantages of this kind of
> interval:
> https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
Thank you for this valuable information you have given. There is
a nice feature used in uniform():
```d
import std;
enum a = 9;
enum b = 10;
void main() {
auto sonYok = generate!(() => uniform!"[)"(a, b)).take(10);
sonYok.writeln; // only 9 (default)
auto ilk_son = generate!(() => uniform!"[]"(a, b)).take(10);
ilk_son.writeln; // may contain 9 & 10
auto orta = generate!(() => uniform!"()"(a, b + 1)).take(10);
orta.writeln; // only 10
auto ilkYok = generate!(() => uniform!"(]"(a, b + 1)).take(10);
ilkYok.writeln; // Does not contain 9
}
```
It would be nice if this feature, which we set up with templates,
could be applied everywhere in D. Because sometimes it is needed.
As for other, I never used this feature until I got used to it.
Of course, it's practical like this, it will do 10 reps:
```foreach(_;0..11)```
Salih
More information about the Digitalmars-d-learn
mailing list