I wrote a code like this
ConstQ[expr_]:=FreeQ[expr,a|c]
in order to verify if some expression contains a or c. Let's call these a end c variable to avoid.
I want to write down something more functional-flavoured: I declare
VariableToAvoid[_]:= False;
VariableToAvoid[a|c]:= True.
and I would like to write a function which does the same as ConstQ neither writing all the variables to avoid inside it nor making VariableToAvoid function to build a list, which doesn't seem very much functional. I'm a bit stuck. Can anyone help me?
EXAMPLE
1) non functional method
FreeQ[CentralDot[a,c],a|c];
which return False
2) functional method
ToAvoid[_]:=False;
ToAvoid[a]:=True;
ToAvoid[c]:=True;
Now I want to get the same result as above on the a generic expression, in this case CentralDot[a,c] without list the variable to avoid
AreThereMyUglyVariablesQ[CentralDot[a,c]]
of course this function must contain some ToAvoid applied to the compoment of the internal exprssion, but I do not know how
ConstQ = FreeQ[a|c]
do what you want? $\endgroup$ConstQ = FreeQ[a|c]
you only do it once. Then you can doConstQ[CentralDot[1,2]], ConstQ[CentralDot[a,c]]
and getTrue
,False
. $\endgroup$