Need help with calling a list of functions

Luigi lewissk at gmail.com
Sun Nov 4 01:17:01 UTC 2018


I need to call a function that can create a function from an 
array of functions and calls them in reverse order.  I am 
learning D any help would be


import std.stdio;
import std.algorithm;
import std.array : array;
import std.range;

auto comp(T)(T function(T) [] list) pure {
     auto backwards = retro(funs);
     return <<HEre is where I think I need some help in calling 
the list of functions with a delegate and fold or reduce>>;
}

void main()
{
     auto fun = comp([(real x)=>a/3.0,(real x)=>x*x,(real 
x)=>x+1.0]);
     writeln(fun(2.0));                // should print 3
}



More information about the Digitalmars-d-learn mailing list