From: Gregory Rickeard
Subject: Newbie needing help
Date: Wed, 24 Jul 2002 10:46:41 +0000
Message-ID: <Pine.GSO.4.33.0207241139230.3290-100000@dixie.dai.ed.ac.uk> Is there a way to convert integers to string format in CL?? From: Kent M Pitman
Subject: Re: Newbie needing help
Date: Wed, 24 Jul 2002 13:35:05 +0000
Message-ID: <sfwadohi706.fsf@shell01.TheWorld.com> Gregory Rickeard <········@sms.ed.ac.uk> writes:
> Is there a way to convert integers to string format in CL??
No.
There are, instead, several ways.
(let ((x 64))
(list (format nil "~R" x) ; cardinal
(format nil "~:R" x) ; ordinal
(format nil ··@R" x) ; roman
(format nil ···@R" x) ; old roman
(format nil "~B" x) ; binary
(format nil "~O" x) ; octal
(format nil "~X" x) ; hex
(format nil "~D" x) ; decimal
(format nil "~3R" x) ; base 3
(format nil "~C" (code-char x)))) ; code => character
=> ("sixty-four"
"sixty-fourth"
"LXIV"
"LXIIII"
"1000000"
"100"
"40"
"64"
"2101"
·@") From: Rolf Wester
Subject: Re: Newbie needing help
Date: Wed, 24 Jul 2002 11:50:22 +0000
Message-ID: <3D3E947E.8060503@ilt.fhg.de> Gregory Rickeard wrote:
>
>
>
> Is there a way to convert integers to string format in CL??
>
>
>
>
>
(defun string-of-int (n)
(format nil "~A" n)) From: Frode Vatvedt Fjeld
Subject: Re: Newbie needing help
Date: Wed, 24 Jul 2002 12:06:53 +0000
Message-ID: <2hn0shwcrm.fsf@vserver.cs.uit.no> Rolf Wester <······@ilt.fhg.de> writes:
> Gregory Rickeard wrote:
>> Is there a way to convert integers to string format in CL??
>>
> (defun string-of-int (n)
> (format nil "~A" n))
Note that this function is dependant on *print-base* et al. "~D" is
probably more correct.
Actually, the problem is underspecified: Which particular string
representation of integers is required?
--
Frode Vatvedt Fjeld