Challenge
Russel Winder via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 30 04:21:12 PDT 2015
On Sun, 2015-08-30 at 10:38 +0000, John Colvin via Digitalmars-d wrote:
> On Sunday, 30 August 2015 at 10:15:14 UTC, John Colvin wrote:
> > 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
>
> Ok, so now I feel stupid. Not only was the unittest I gave above
> broken anyway, I realised what my underlying problem was within
> minutes of posting...
So what was the problem?
> Carry on, nothing to see here...
See aboveā¦
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
More information about the Digitalmars-d
mailing list