3
$\begingroup$

When I write ToString[a->b], regardless of whether the input uses the right-arrow symbol or - and > separately, it comes out as "a -> b" with - and >. If I just write "->" but with the right-arrow symbol, that's what I get in the output, so it's possible to get the arrow to show up in a string, but is there a good way to do this without having to break up the expression before using ToString?

$\endgroup$
2
  • 1
    $\begingroup$ does ToString[a -> b, StandardForm] give what you want? $\endgroup$ – kglr Dec 14 '20 at 0:30
  • $\begingroup$ @kglr Yes, thank you! $\endgroup$ – Blrp Dec 14 '20 at 0:34
3
$\begingroup$

You can use StandardForm in the second argument of ToString:

ToString[a -> b, StandardForm]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.