How to make a function table?
mnar53
maurizionardo at hotmail.it
Sat Feb 16 05:06:55 UTC 2019
Absolutely a newbie to D. This code mimics c, but unfortunately
does not work:
import std.typecons;
import std.math;
alias double function(double) UNARY;
UNARY[] FCNS = [sin, cos, tan];
double[][] MAP (int idx, double[][] args) nothrow {
UNARY f = FCNS[idx];
foreach(i; 0 .. args.length)
foreach(j; 0 .. args[i].length)
args[i][j] = f (args[i][j]);
return args;
}
what's wrong with it?
More information about the Digitalmars-d-learn
mailing list