http://d.puremagic.com/issues/show_bug.cgi?id=4264



--- Comment #3 from bearophile_h...@eml.cc 2010-07-16 13:19:18 PDT ---
> The problem with the last example seems to be that the
> template arguments to 'to' are in the wrong order.

But this too doesn't work:

import std.algorithm, std.conv, std.range;
void main() {
    auto r1 = map!(to!(string, uint))(iota(20));
}


import std.algorithm, std.conv, std.range;
void main() {
    auto r1 = map!(to!(string, int))(iota(20));
}

------------------

> Also, how can the opApply example work with lazy iteration?
> As far as I know opApply does not provide any way to pause and resume
> iteration.

If you perform a map! on an iterable that has a length, then map! detects it at
compile-time and offers a length attribute, otherwise it's not offered.

So map! and other similar higher order functions can adapt and offer as much as
possible.

If the iterable given to map! has just an opApply, then map! can offer just an
opApply, for an iteration that can't be resumed.

------------------

> It would be possible on the other hand to allow array to work on
> anything that supplies opApply.

array() can work with anything that can be iterated by foreach.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to