Compiler errors and recursive nested functions

Ali Çehreli acehreli at yahoo.com
Wed Jun 12 15:55:05 PDT 2013


On 06/12/2013 03:49 PM, Dylan Knutson wrote:

 > DPaste has stopped responding to requests at the time of writing,

Being an old ;) old-timer I never understood the need for those sites.

 > ----
 > import std.algorithm : map;
 > import std.range : isInputRange, ElementType;

As a workaround, make that lambda a free-standing function here:

auto intermediate(T, alias pred)(T a)
{
     return a.deepMap!(pred)();
}

 > // Neither does this, for the same reason
 > auto deepMap(alias pred, Range)(Range r)
 > if(isInputRange!Range)
 > {
 >      static if(isInputRange!(ElementType!Range))
 >      {
 >          return r.map!( a => a.deepMap!(pred)() )();

And use that free-standing instead:

         return r.map!(intermediate!(ElementType!Range, pred))();

Ali



More information about the Digitalmars-d-learn mailing list