8
$\begingroup$

I would like to generate a list of the symbols for the planets to include in a nice table with other data. How can I programmatically generate (eg. using a pure function) the symbols from a list of the planets' names as strings.

Such an input list is generated as follows:

AstronomicalData["Planet"]

{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}

If I can do it for one name, then it's solved. Doing it manually by typing \[Saturn] produces the desired symbol , but doing it manually is not a desirable option.

The following attempt fails in any case:

\[#] & /@ {"Saturn"}
$\endgroup$

2 Answers 2

12
$\begingroup$
ToExpression["\\[" <> # <> "]"] & /@ {"Mercury", "Venus", "Earth", 
  "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}

Gives

enter image description here

(also corrected the code thanks to Kuba)

$\endgroup$
0
5
$\begingroup$

Alternatively:

CommonName[EntityClass["Planet", All]["Glyph"]]

or just

EntityClass["Planet", All]["Glyph"]

if you don't mind the Entity formatting.

$\endgroup$
2
  • 1
    $\begingroup$ You can also do EntityValue[EntityClass["Planet", All]["Glyph"], "Name"]. $\endgroup$
    – Greg Hurst
    May 28, 2015 at 14:35
  • $\begingroup$ @ChipHurst Good call! Or even Through[EntityClass["Planet", All]["Glyph"]["Name"]] $\endgroup$
    – chuy
    May 28, 2015 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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