Suppose I have two lists of the equal length in the form
powers= {{rho th},{mu},{beta},{nu},{r},{}}
subscripts={{ }, {a}, {th}, {b}, {r},{mu,al}}
If there is a repeated element (one in the first list and other one in the second list) which I specify (for example in this case it is mu
, but not r
) then I remove it from both lists and create an element with the rest, for example in this case the out put should be
powers= {{rho th},{beta},{nu},{r},{ }}
subscripts={{ }, {th}, {b}, {r},{a,al}}
I got the removing part
DeleteCases[powers,mu,Infinity]
DeleteCases[subscripts,mu,Infinity]
but struggling with the rest.
UPDATE:
I found how to combine the elements, now just need to remove $mu$ from them, but DeleteCases
does not work.
posmu1=Position[power,mu][[1,1]]
posmu2=Position[subscipts,mu][[1,1]]
Flatten[powers[[posmu1]]powers[[posmu2]]]
It gives {mu rho th}
, but now I cannot delete mu
from it using DeleteCases
.
a
andal
part of the same sublist in the output? $\endgroup$ – Szabolcs Feb 12 '15 at 1:29{{ }, {a,al}, {th}, {b}, {r}}
? What if there's more than onemu
in both lists? The clearer the question, the better your chances for an answer. $\endgroup$ – Szabolcs Feb 12 '15 at 1:42