4.16 How to obtain a list of all arguments of a single function in an expressions?

Given an expression, we want to find list of all the arguments of such function, say \(y(.)\) in that expression. This can be used for example to check if the arguments of such a function are valid during parsing.

One way is to use indets to select all such functions from the expression, then use op as above to find the arguments. Here is an example

expr:=y(3)+y(x)+7+y(Pi)+y([a+b])+h(z)+exp(x); 
L:=indets(expr,'specfunc'(anything,y)); 
map(X->op(1,X),L); 
 
    {3, Pi, x, [a + b]}