I would like to write a searcher like FreeQ
that looks for a Symbol
(or Head
) in an expression, but confines its search outside of subexpressions that have a particular Head
. Because expr
can get huge, it is especially important to minimize the search time.
For example, I might want to test whether expr
is free of Symbol
=a
outside of Head
=func
:
expr1 = a * b + c * func[a,x]
expr2 = b^2 + d * func[a,c]
Let's call this new searcher subFreeQ[expr_, symb_, head_]
. Then I would like:
subFreeQ[expr1, a, func]
(*False*)
subFreeQ[expr2, a, func]
(*True*)