On Wednesday, 10 June 2020 at 00:53:30 UTC, Seb wrote:
[snip]
Anyhow, I would be highly in favor of DMD doing this. It's one
of those many things that I have on my list for D3 or a D fork.
Chapel supports zippered iteration [1]. From the discussion here,
it sounds very much like the
On Wednesday, 10 June 2020 at 15:34:57 UTC, Steven Schveighoffer
wrote:
My biggest problem with enumerate is that you can't bind the
tuple to parameters for something like map:
arr.enumerate.map!((idx, val) => ...)
doesn't work. Instead you have to do:
arr.enumerate.map!((tup) => ...)
And
On 6/9/20 7:53 PM, Q. Schroll wrote:
Is there any particular reason why std.range : enumerate is a thing and
foreach (i, e; range) { ... }
doesn't work from the get-go? I wouldn't have such an issue with it if
static foreach would work with enumerate just fine.
What is the use case for
On Tuesday, 9 June 2020 at 23:53:16 UTC, Q. Schroll wrote:
Is there any particular reason why std.range : enumerate is a
thing
Someone already mentioned dictionary.
Consider that most ranges don't actually have an index. In this
case you aren't actually asking to add indexes, but a count of
On Wednesday, 10 June 2020 at 01:35:32 UTC, Q. Schroll wrote:
On Wednesday, 10 June 2020 at 00:53:30 UTC, Seb wrote:
It's a bit more complicated though as you need to avoid subtle
breakage with ranges that return tuples that are auto-expanded
like e.g. `foreach (k,v; myDict)`.
Okay, I can
On Wednesday, 10 June 2020 at 00:53:30 UTC, Seb wrote:
It's a bit more complicated though as you need to avoid subtle
breakage with ranges that return tuples that are auto-expanded
like e.g. `foreach (k,v; myDict)`.
Okay, I can accept that. It's a poor decision, but well, it is
what it is.
On Tuesday, 9 June 2020 at 23:53:16 UTC, Q. Schroll wrote:
Is there any particular reason why std.range : enumerate is a
thing and
foreach (i, e; range) { ... }
doesn't work from the get-go? I wouldn't have such an issue
with it if static foreach would work with enumerate just fine.
As
On Tuesday, 9 June 2020 at 23:53:16 UTC, Q. Schroll wrote:
Is there any particular reason why std.range : enumerate is a
thing and
[...]
I don't think there is any particular reason. Other than that
might shadow an opApply.
And C++ iterators didn't have it.
On Tue, Jun 09, 2020 at 05:03:55PM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
> On Tue, Jun 09, 2020 at 11:53:16PM +, Q. Schroll via Digitalmars-d-learn
> wrote:
> > Is there any particular reason why std.range : enumerate is a thing
> > and
> >
> > foreach (i, e; range) { ... }
>
On Tue, Jun 09, 2020 at 11:53:16PM +, Q. Schroll via Digitalmars-d-learn
wrote:
> Is there any particular reason why std.range : enumerate is a thing
> and
>
> foreach (i, e; range) { ... }
>
> doesn't work from the get-go?
[...]
std.range.indexed is your friend. ;-)
T
--
Let's eat
10 matches
Mail list logo