If you want to see what are the real "words" behind the expression {-x,y,-z,a} try : FullForm[{-x,y,-z,a}], you will see there no Minus, so your replacement rule will have no effect.
– andre314Mar 28 '16 at 15:27
1
I didn't know about the FullForm expression yet. Thank you for that, that may create lots less struggle in the future with similar problems :)
– JasperMar 28 '16 at 15:31
If you get the Head of first element: list={-x,y,-z,a}; Head[list[[1]]] you see that it is Times whereas the second element's head is Symbol so you can extract negative and positive elemtns separately and do whatever modification you need on them. For example: Join[-1*Cases[list,Except[_Symbol]],Cases[list,_Symbol]]
– MathXMar 28 '16 at 17:34
-1*x_ :> x– Marius Ladegård Meyer Mar 28 '16 at 15:17{-x, y, -z, a} /. -t_ :> tworks too. – andre314 Mar 28 '16 at 15:21{-x,y,-z,a}try :FullForm[{-x,y,-z,a}], you will see there noMinus, so your replacement rule will have no effect. – andre314 Mar 28 '16 at 15:27Headof first element:list={-x,y,-z,a}; Head[list[[1]]]you see that it isTimeswhereas the second element's head isSymbolso you can extract negative and positive elemtns separately and do whatever modification you need on them. For example:Join[-1*Cases[list,Except[_Symbol]],Cases[list,_Symbol]]– MathX Mar 28 '16 at 17:34