How to test if the first character in a symbol is a letter in lisp?

2.8k views Asked by At

How to test if the first character in a symbol is a letter in lisp? I know it has something to do with the alpha-char-p function.

1

There are 1 answers

2
Anton Kovalenko On

Like this:

(alpha-char-p (char (string 'my-symbol) 0))

string converts a string designator to a string. Some comments here suggest that it's too general and it's better to use symbol-name which will refuse to work with anything but symbols. I believe that an interface accepting string designators is a better match for a request for the first character of a symbol.