My goal is to have NumericQ[h[j]]=True for any j regardless of whether j may be symbolic with no defined value.
Setting NumericQ[h[j_]]=True does not work and as I understand the NumericFunction attribute only works when the input is also numeric.
One solution might be to unprotect NumericQ and then set NumericQ[h[j_]]=True but I have not tried this as I am afraid of using Unprotect. Another solution might be to define my own NumericQ function, that I can call numericq for example, and set numericq[h[j_]]=True but I would have to replace all previous NumericQ with numericq in my code and test that everything works.
- edit *
I want to do this because I want my code to ignore certain symbols. My solution was to treat these symbols as numeric but this does not work for symbols like h[j] when j is a generic symbol. Any other function that works like NumericQ could work although I would have to change my code a bit.
NumericQ[]
. $\endgroup$NumericQ
, you could use an upvalue as inh/:HoldPattern[NumericQ[h[_]]]=True
. I am not saying that it is a good idea. Btw: Somewhat surprisingly to me, even something likeNumericQ[undefinedsymbol]=True
gives no error. I do not understand why it gives no error,NumericQ
is protected, not sure what I am missing. $\endgroup$