flatMap

各要素にある関数を適用し、それらを結合します。 つまり、r.map!fun.concatと等価です

flatMap
(
alias fun
R
)
(
R r
)
if (
isInputRange!R
)

Examples

1 debug scope(failure) writefln("Unittest Failure :%s(%s) ", __FILE__, __LINE__);
2 debug scope(success) {writefln("Unittest Success :%s(%s)", __FILE__, __LINE__); stdout.flush();}
3 
4 auto r1 = [1, 2, 3, 4];
5 assert(equal(r1.flatMap!"repeat(a, a)", [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]));
6 
7 auto r2 = ["a b c", "de f", "ghi", "jkl mn"];
8 assert(equal(r2.flatMap!split, ["a", "b", "c", "de", "f", "ghi", "jkl", "mn"]));
9 
10 auto r3 = [1, 2];
11 assert(equal!equal(r3.flatMap!"repeat(a, a).repeat(a)",
12     [[1], [2, 2], [2, 2]]));

Meta