Challenge
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 30 03:15:12 PDT 2015
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
More information about the Digitalmars-d
mailing list