import std.algorithm, std.range;

auto foo(R)(R a, immutable int b)
{
    return a.map!(x => x + b);
}

unittest @nogc @safe
{
    int[] test = [1,2,3];

    assert(test.foo(3).equal(only(4,5,6)));
}

Challenge: reimplement `foo` such that above unittest will compile. No cheating with malloc etc. Bonus points if you don't have to implement a modified version of std.algorithm.map

Reply via email to