tmap

tmap

  1. auto tmap(T args)
    template tmap(fun...)
    tmap
    (
    T...
    )
    ()
    if (
    T.length > 1 ||
    (
    T.length == 1 &&
    !__traits(compiles, ElementType!(T[0]).Types)
    )
    )
    if (
    fun.length >= 1
    )
  2. auto tmap(T args)

Members

Functions

tmap
auto tmap(T args)
Undocumented in source. Be warned that the author may not have intended to support it.
tmap
auto tmap(T args)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

TMap
struct TMap(bool asB, T...)
Undocumented in source.

Examples

ditto

debug scope(failure) writefln("Unittest Failure :%s(%s) ", __FILE__, __LINE__);
debug scope(success) {writefln("Unittest Success :%s(%s)", __FILE__, __LINE__); stdout.flush();}

auto r1 = [1, 3, 2, 4, 0, 0];
auto s = "abc".dup;
auto tm1 = tmap!("a", "b", (a, b) => b.repeat(a).array().idup)(r1, s);
assert(equal(tm1, [tuple(1, 'a', "a"d),
                   tuple(3, 'b', "bbb"d),
                   tuple(2, 'c', "cc"d)]));

assert(tmap!"a"(r1, s, "").empty);

auto r3 = [1, 2, 3];
//first element of [0] expresses r3 is used as range, but second element expresses "abcd" is not used as range.
auto ss = tmap!("b[a]", [0])(r3, "abcd");
assert(equal(ss, ['b', 'c', 'd'][]));
assert(ss.length == 3);
assert(equal(ss, ss.save));

static assert(isForwardRange!(typeof(ss)));
static assert(!isBidirectionalRange!(typeof(ss)));
static assert(!isRandomAccessRange!(typeof(ss)));

auto ss_b = ss.asBidirectional;
static assert(isBidirectionalRange!(typeof(ss_b)));
static assert(isRandomAccessRange!(typeof(ss_b)));
assert(equal(ss_b.retro, ['d', 'c', 'b']));

///multi function and range-choose test
auto tm5 = tmap!("b[a]", "b[a-1]", [0])(r3, "abcd");
assert(equal(tm5, [tuple('b', 'a'), tuple('c', 'b'), tuple('d', 'c')][]));

Meta