Hi everybody !!
How can I transform single characters (like 'A, 'B, 'C) in strings which
contain 1 character (respectively "A", "B", "C") ?
Please tell it me !! It should'nt be complicated !!
"Olivier Pin�on" <·······@wanadoo.fr> writes:
>
> Hi everybody !!
>
> How can I transform single characters (like 'A, 'B, 'C) in strings which
> contain 1 character (respectively "A", "B", "C") ?
Just to be pedantic, the objects 'A, 'B, 'C, etc. are not CHARACTERs,
but rather SYMBOLs. Common Lisp has a separate CHARACTER type which
would be written as #\A, #\B, #\C, etc.
> Please tell it me !! It should'nt be complicated !!
As another poster revealed, calling SYMBOL-NAME on a symbol will return
the name of that symbol as a string. This, of course, works on symbols
with arbitrary length names.
A more interesting question is why do you want to do this? Often
questions like yours mask other, more interesting and fundamental
questions about how to accomplish a particular task.
--
Thomas A. Russ, USC/Information Sciences Institute ···@isi.edu
* "Olivier Pin�on" <·······@wanadoo.fr>
| How can I transform single characters (like 'A, 'B, 'C) in strings which
| contain 1 character (respectively "A", "B", "C") ?
|
| Please tell it me !! It should'nt be complicated !!
'A, 'B, and 'C aren't characters, they are (quoted) symbols.
if you want a mapping from string to symbol, it's INTERN (creates it) or
FIND-SYMBOL (looks it up, only). if you want a mapping from symbol to
string, it's SYMBOL-NAME.
#\A, #\B, and #\C are characters. if you have a string of length one or
a symbol whose symbol-name is a string of length one, CHARACTER will
return the corresponding character.
(character 'a) => #\A
if you want to create a string out of a character, STRING will do that:
(string #\a) => "a"
which textbook or reference manual are you using?
[I have assumed Common Lisp in the absence of any contrary information.]
#:Erik
--
suppose we blasted all politicians into space.
would the SETI project find even one of them?
In article <············@wanadoo.fr>,
Olivier Pin�on <·······@wanadoo.fr> wrote:
>Hi everybody !!
>
>How can I transform single characters (like 'A, 'B, 'C) in strings which
>contain 1 character (respectively "A", "B", "C") ?
>
>Please tell it me !! It should'nt be complicated !!
You may want symbol-name:
EC(1): (symbol-name 'a)
"A"
EC(2):
I'm not sure I completely understand you, though.
-- Mark