reflection based on my experience so far on compile-time meta-programming in D as a novice user: the problems
mw
mingwu at gmail.com
Mon Sep 14 23:17:09 UTC 2020
On Monday, 14 September 2020 at 22:20:15 UTC, H. S. Teoh wrote:
> with, and your Github links are dead. Instead of assuming a
Sorry, I changed the dir structure, but the git repo root always
stay the same:
https://github.com/mingwugmail/talibd
Maybe you didn't follow the discussion very closely, but I think
both Paul and Steven knows what I'm trying to do.
Never mind, let's start from fresh again, here is the *challenge*:
in this generated file:
https://github.com/mingwugmail/talibd/blob/master/source/talibd/talib_func.d
Notice the similarity, but different parameters of these 3
functions:
bool TA_MA(double[] inData , double[] outMA , int
MA_optInTimePeriod=default_MA_optInTimePeriod, TA_MAType
optInMAType=default_optInMAType) { ... }
bool TA_RSI(double[] inData , double[] outRSI , int
RSI_optInTimePeriod=default_RSI_optInTimePeriod) { ... }
bool TA_MACD(double[] inData , double[] outMACD, double[]
outMACDSignal, double[] outMACDHist , int
optInFastPeriod=default_optInFastPeriod, int
optInSlowPeriod=default_optInSlowPeriod, int
optInSignalPeriod=default_optInSignalPeriod) { ... }
https://github.com/mingwugmail/talibd/blob/master/source/talibd/talib_func.d#L51
https://github.com/mingwugmail/talibd/blob/master/source/talibd/talib_func.d#L79
https://github.com/mingwugmail/talibd/blob/master/source/talibd/talib_func.d#L104
These are the target functions we want to generate.
Now the goal: write a single function template to generate these
3 functions in D, better not to use the very raw string
interpolation :-)
More information about the Digitalmars-d
mailing list