4.6 How to find symbols inside csgn() in an expression?

Given  sol:=1/2*2^(1/2)*csgn(x)*x*csgn(y);  how to find all symbols inside csgn which will be \(x,y\) in this case?

restart; 
sol:=1/2*2^(1/2)*csgn(x)*x*csgn(y); 
indets(sol,'specfunc( anything, csgn )'); 
vars:=subsindets(%,'specfunc( anything, csgn )',f->op(f))
 

Gives {x, y}

Now if we want to simplify the above solution by assuming that all variables inside vars are positive, how to do that?

restart; 
sol:=1/2*2^(1/2)*csgn(x)*x*csgn(y); 
indets(sol,'specfunc( anything, csgn )'); 
vars:=subsindets(%,'specfunc( anything, csgn )',f->op(f)); 
simplify(sol) assuming op(map2(`<`,0,vars))
 

Gives \(\frac {\sqrt {2}\, x}{2}\). Notice in the above the use of op(map2(`<`,0,vars)), this will generate the sequence 0 < x, 0 < y automatically. op is needed otherwise the result will be {0 < x, 0 < y} which will give syntax error when passed to assuming

Ofcourse, it would have been also possible to just write

simplify(sol) assuming positive;
 

And get the same result. But sometimes we might want to specify which variables are to be assumed positive and not all of them at once in the expression.