[Issue 4468] std.string.join() for lazy iterable of strings

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 21 10:33:40 PST 2011


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


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from bearophile_hugs at eml.cc 2011-12-21 10:33:37 PST ---
Now in DMD 2.057 this works:

import std.stdio, std.algorithm, std.conv, std.range, std.string;
void main() {
    auto r = map!("to!string(a)")(iota(20));
    //string result = join(array(r), ""); // OK
    string result = join(r, ""); // error
    writeln(result);
}


This line:
auto r = map!("to!string(a)")(iota(20));
is also better written:
auto r = map!text(iota(20));


But this doesn't work still:

import std.range;
void main() {
    auto aa = [1:["hello", "red"], 2:["blue", "yellow"]];
    auto r2 = join(aa.byValue()); // error
}


To make this work there are two solutions:
1) Change byValue() to return a Range.
2) Change join() to accept an opApply too.

The first solution allows to use byValue in many other cases, so I think join()
is OK, and I close this bug report.

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


More information about the Digitalmars-d-bugs mailing list