Lime
Lime

Reputation: 13532

Lisp return String of Symbol name

Basically I'm looking for a function that does the opposite of the following.

(intern "CAR")

This question is related. In Common Lisp, is there a function that returns a symbol from a given string?

Upvotes: 4

Views: 1735

Answers (2)

Vatine
Vatine

Reputation: 21258

Either string or symbol-name would work to get the name of a symbol.

If you know specifically that you're passing n a symbol, symbol-name might allow both a compiler to generate better code as well as signal to a human reader that the argument is expected to be a symbol.

Upvotes: 7

Renzo
Renzo

Reputation: 27424

The operator you are looking for is string (see the manual):

(string (intern "CAR"))

returns "CAR".

Upvotes: 8

Related Questions