concat

concats elements

  1. auto concat(R range)
    concat
    (
    R
    )
    ()
    if (
    isRangeOfRanges!R
    )
  2. R concat(R range)

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 int[][] r1 = [[0, 1, 2, 3], [4, 5, 6], [7, 8], [9], []];
5 auto c = concat(r1);
6 assert(equal(c, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
7 assert(equal(c.retro(), retro([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))); // bidir range
8 assert(equal(c.retro.retro, c));
9 
10 assert(equal(concat(c), c));
11 
12 auto r2 = [0, 1, 2, 3, 4, 5];
13 assert(equal(r2.map!"[a, 2]".concat, [0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2]));
14 assert(equal(r2[0 .. 4].map!(a => repeat(a, a)).concat, [1, 2, 2, 3, 3, 3]));
15 assert(equal(r2[0 .. 3].repeat(2).map!(map!"a + 1").concat, [1, 2, 3, 1, 2, 3]));
16 
17 int[] emp;
18 assert(emp.repeat(15).concat.empty);
19 assert(emp.concat.empty);

Meta