EDIT: Added that I want to extract not only the variables from a specific set, but also functions involving variables from a specific set.
Given the set
S = [s1, s2, s3]
and some vector of values
x = {1, 2, 4, s1, y, f1[s1], f2[s2]}
I want to pick out all values in x
that belong to the set S
, and also all functions involving arguments with from the set S
. Maybe some approach like
Smash[x_] := Cases[{x}, _, {0, Infinity}] (*Eq. Smash[f1[s1]] = {f1[s1],s1})
Select[x, IntersectingQ[Smash[#], S] ]
But it really doesn't work. I guess it's an issue regarding the syntax mainly, I don't really know what do with #
. How can I solve this? Any answers explaining the syntax issue or giving alternative solutions will be greatly appreciated.
Intersection[S,x]
.(iv) to make you own code work just put an & at the end of your criterion $\endgroup$