# How can i replace the symbols in a list?

As you can see from the picture, how can I change all the "->" symbols to "-"?

Look at the FullForm of a Rule

a -> b // FullForm

(* Rule[a, b] *)

SeedRandom[1234];

b3 = Thread[{a, b, c, d, e} -> RandomInteger[100, 5]]

(* {a -> 8, b -> 72, c -> 44, d -> 38, e -> 22} *)

b3 /. Rule[a_, b_] :> StringForm["-", a, b]


or with some space

b3 /. Rule[a_, b_] :> StringForm["\[ThinSpace]-\[ThinSpace]", a, b]


• Thanks for your answer, Mr Hanlon, I completely got the "-" symbol, but I faced another trouble. How can I transform the output into dataset? I tried to use Dataset function, but it showed lots of symbols different from the output. – Liming Zhou Mar 22 at 7:24
• b3 = Thread[{a, b, c, d, e} -> RandomInteger[100, 5]]; Dataset[Association[b3]] – Bob Hanlon Mar 22 at 7:30
• Oh! I just got the same anser with Dataset function, there are lots of mess symbols. – Liming Zhou Mar 22 at 7:46
• Post a question showing data (for a small sample) and your code. Note that you cannot be be using the transformation of the Rule shown above since the rules must remain to form the association. – Bob Hanlon Mar 22 at 7:50
• For example: c1 = {x, y, z};c2 = {1, 2, 3};c3 = Thread[c1 -> c2] I want to get the dataset of c3, and when I just use Dataset function, it shows "->" symbol, I want to replace it with symbol "-". – Liming Zhou Mar 22 at 8:25

a->b is a shortcut for Rule[a,b]. Therefore, what you have to do is to replace Ruleby Subtract. E.g.:

SeedRandom[1]
list = Thread[{a, b, c, d, e} -> RandomInteger[100, 5]]

(* {a -> 80, b -> 14, c -> 0, d -> 67, e -> 3} *)

list /. Rule -> Subtract

(*  {-80 + a, -14 + b, c, -67 + d, -3 + e}  *)

• Thanks for your answer, Mr Huber, but I want to get the "-" as only symbol but ont subtract. – Liming Zhou Mar 22 at 7:20
• If you want a string form: StringReplace[ToString[list], "->" -> "-"] – Daniel Huber Mar 22 at 10:42
• This is a good method, but I want to get a dataset in the end. – Liming Zhou Mar 22 at 14:19