a simplification problem



Js:{};
s(x):= if (not(atom (x)) and inpart(x,0)=J )then Js:union(Js,{x});
apply1(t2,s)$
Js;
 
I suspect it is faster, but it is certainly shorter.