Combining infinite ranges
bearophile
bearophileHUGS at lycos.com
Wed Jun 2 18:04:04 PDT 2010
Andrei Alexandrescu:
> No need to write enumerate() - it's zip(iota(0, size_t.max), r).
What does it happen if someone gives you the sequence produced by:
zip(r, iota(0, size_t.max))
?
You have can require an adaptor because it's not the standard convention.
While enumerate() always gives you indexes at the first place. And the index/item fields have a standard name that you remember in your code.
Finding the minimal number of pieces to do something is useful, but sometimes if an operation is common enough it can be useful to give it a new name. It's called chunking.
Inside an expression that can contain other stuff do you prefer to use:
zip(iota(0, size_t.max), items)
or
enumerate(items)
?
The second makes the expression shorter and more readable in its purpose.
Bye,
bearophile
More information about the Digitalmars-d
mailing list