Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Character conversion !!

2 views
Skip to first unread message

Olivier Pinçon

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
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 !!

Erik Naggum

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
* "Olivier Pinçon" <opi...@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?

Mark Carroll

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
In article <7njrun$2nq$1...@wanadoo.fr>,
Olivier Pinçon <opi...@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

Thomas A. Russ

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
"Olivier Pinçon" <opi...@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 t...@isi.edu

0 new messages