%mathpiper,def="HasFuncSome"

/// function name given as string.
10 # HasFuncSome(_expr, string_IsString, _look'list) <-- HasFuncSome(expr, ToAtom(string), look'list);
/// function given as atom.
// atom contains no functions
10 # HasFuncSome(expr_IsAtom, atom_IsAtom, _look'list) <-- False;
// a list contains the function List so we test it together with functions
// a function contains itself, or maybe an argument contains it

// first deal with functions that do not belong to the list: return top level function
15 # HasFuncSome(expr_IsFunction, atom_IsAtom, _look'list)_(Not Contains(look'list, ToAtom(Type(expr)))) <-- IsEqual(First(FunctionToList(expr)), atom);
// function belongs to the list - check its arguments
20 # HasFuncSome(expr_IsFunction, atom_IsAtom, _look'list) <-- IsEqual(First(FunctionToList(expr)), atom) Or ListHasFuncSome(Rest(FunctionToList(expr)), atom, look'list);

%/mathpiper



%mathpiper_docs,name="HasFuncSome",categories="User Functions;Predicates"
*CMD HasFuncSome --- check for expression containing a function
*STD
*CALL
	HasFuncSome(expr, func, list)

*PARMS

{expr} -- an expression

{func} -- a function atom to be found

{list} -- list of function atoms to be considered "transparent"

*DESC

The command {HasFuncSome} does the same thing as {HasFunc}, except it only looks at arguments of a given {list} of functions. Arguments of all other functions become "opaque" (as if they do not contain anything).

Note that since the operators "{+}" and "{-}" are prefix as well as infix operators, it is currently required to use {ToAtom("+")} to obtain the unevaluated atom "{+}".

*E.G.

In> HasFuncSome({a+b*2,c/d},/,{List})
Result: True;
In> HasFuncSome({a+b*2,c/d},*,{List})
Result: False;

*SEE HasFunc, HasFuncArith, FuncList, VarList, HasExpr
%/mathpiper_docs