From: Trastabuga
Subject: Newbie: Inverse function for char-code?
Date: 
Message-ID: <1138750688.803019.176620@g43g2000cwa.googlegroups.com>
Hi

I wonder if I could call some function that would give me the character
based on it's code?
Let's say I need to convert from digit to string (without using format)
so I'd need some function that would convert "5 + (char-code #\0)" a
character #\5. I tried to play with coerce but with no luck.

Thank you,
Andrei

From: vedm
Subject: Re: Newbie: Inverse function for char-code?
Date: 
Message-ID: <yICdnUi7dd2pv33eRVn-uA@giganews.com>
"Trastabuga" <·········@gmail.com> writes:

> Hi
>
> I wonder if I could call some function that would give me the character
> based on it's code?
> Let's say I need to convert from digit to string (without using format)
> so I'd need some function that would convert "5 + (char-code #\0)" a
> character #\5. I tried to play with coerce but with no luck.

Look at my signature.

-- 
vedm

(format t "~{~a~}"
        (mapcar #'(lambda (c) (code-char (1+ (char-code c))))
                (reverse (list #\l #\n #\b (code-char (1- (char-code #\.)))
                               #\m #\h (code-char (1- (char-code #\a))) #\m #\y
                               (code-char (1- (char-code ··@)))  #\l #\c #\d #\u))))
From: Carl Taylor
Subject: Re: Newbie: Inverse function for char-code?
Date: 
Message-ID: <_KSDf.316158$qk4.188438@bgtnsc05-news.ops.worldnet.att.net>
"Trastabuga" <·········@gmail.com> wrote in message 
·····························@g43g2000cwa.googlegroups.com...
> Hi
>
> I wonder if I could call some function that would give me the character
> based on it's code?
> Let's say I need to convert from digit to string (without using format)
> so I'd need some function that would convert "5 + (char-code #\0)" a
> character #\5.

CL-USER 5 > (code-char (+ 5 (char-code #\0)))
#\5

clt 
From: Carl Taylor
Subject: Re: Newbie: Inverse function for char-code?
Date: 
Message-ID: <8PSDf.316169$qk4.266311@bgtnsc05-news.ops.worldnet.att.net>
"Carl Taylor" <··········@att.net> wrote in message 
····························@bgtnsc05-news.ops.worldnet.att.net...
>
> "Trastabuga" <·········@gmail.com> wrote in message 
> ·····························@g43g2000cwa.googlegroups.com...
>> Hi
>>
>> I wonder if I could call some function that would give me the character
>> based on it's code?
>> Let's say I need to convert from digit to string (without using format)
>> so I'd need some function that would convert "5 + (char-code #\0)" a
>> character #\5.
>
> CL-USER 5 > (code-char (+ 5 (char-code #\0)))
> #\5

I should also have mentioned:

CL-USER 6 > (digit-char 5)
#\5

clt 
From: Thomas A. Russ
Subject: Re: Newbie: Inverse function for char-code?
Date: 
Message-ID: <ymipsm6q4gx.fsf@sevak.isi.edu>
"Carl Taylor" <··········@att.net> writes:

> "Carl Taylor" <··········@att.net> wrote in message
> >
> > CL-USER 5 > (code-char (+ 5 (char-code #\0)))
> > #\5
> 
> I should also have mentioned:
> 
> CL-USER 6 > (digit-char 5)
> #\5

Which is a slightly preferable approach, since Common Lisp doesn't
require the ASCII character set.  The only requirement imposed on the
character set is that digits be properly ordered from 0-9, but they
don't have to be contiguous.  I believe EBCDIC has non-contiguous
alphabetic characters.

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: David Sletten
Subject: Re: Newbie: Inverse function for char-code?
Date: 
Message-ID: <e4UDf.5817$Ou1.3727@tornado.socal.rr.com>
Trastabuga wrote:
> Hi
> 
> I wonder if I could call some function that would give me the character
> based on it's code?
> Let's say I need to convert from digit to string (without using format)
> so I'd need some function that would convert "5 + (char-code #\0)" a
> character #\5. I tried to play with coerce but with no luck.
> 
> Thank you,
> Andrei
> 

This is not a particularly inspiring question. However, for future 
reference you can use the "Permuted Symbol Index" of the Common Lisp 
HyperSpec to explore names that are related (which may correspond to 
concepts that are related):
http://www.lispworks.com/documentation/HyperSpec/Front/X_Symbol.htm

In fact, if you look at the middle of the "c" page:
http://www.lispworks.com/documentation/HyperSpec/Front/X_Perm_C.htm
you will note that right under the link for CHAR-CODE there is a link to 
  CODE-CHAR.

Aloha,
David Sletten