I am trying to concatenate a symbol and number into a symbol. I am kinda
a newbie so I am not that familiar with lisp API. Here is how i thought
about doing it.
A - convert the symbol to a string.
B - convert the number to a string.
C - concatenate the two above values.
D - Intern the resulting string.
I can do steps A, C, D using symbol-name, concatenate, and Intern
functions respectively. However I don't know of a function that converts
a number to a string. So help me out here with step B...
Also is there another way of doing all of this.
Thanx.
In article <············@news-int.gatech.edu>, lama <····@yahoo.com> wrote:
> I am trying to concatenate a symbol and number into a symbol. I am kinda
> a newbie so I am not that familiar with lisp API. Here is how i thought
> about doing it.
>
> A - convert the symbol to a string.
> B - convert the number to a string.
> C - concatenate the two above values.
> D - Intern the resulting string.
>
> I can do steps A, C, D using symbol-name, concatenate, and Intern
> functions respectively. However I don't know of a function that converts
> a number to a string. So help me out here with step B...
princ-to-string
> Also is there another way of doing all of this.
You can use make-symbol instead of intern. But you're basically doing it
right. However, it's almost certainly not what you really want to do,
especially if you're a newbie. So you're probably doing the wrong thing,
but you're doing it correctly.
:-)
E.
lama <····@yahoo.com> writes:
> I am trying to concatenate a symbol and number into a symbol. I am
> kinda a newbie so I am not that familiar with lisp API. Here is how i
> thought about doing it.
>
> A - convert the symbol to a string.
> B - convert the number to a string.
> C - concatenate the two above values.
> D - Intern the resulting string.
>
> I can do steps A, C, D using symbol-name, concatenate, and Intern
> functions respectively. However I don't know of a function that
> converts a number to a string. So help me out here with step B...
>
> Also is there another way of doing all of this.
You can pass (format nil "~a~a" 'X 0) to either intern or make-symbol.
--
John M. Adams
·······@stsci.edu (John M. Adams) writes:
> You can pass (format nil "~a~a" 'X 0) to either intern or make-symbol.
This is sensitive to the value of *print-case*, at least. You can use
with-standard-io-syntax to avoid that problem, but then you need to
make sure to rebind *package*.
^L
Louis Theran wrote:
> ·······@stsci.edu (John M. Adams) writes:
>
>>You can pass (format nil "~a~a" 'X 0) to either intern or make-symbol.
>
>
> This is sensitive to the value of *print-case*, at least. You can use
> with-standard-io-syntax to avoid that problem, but then you need to
> make sure to rebind *package*.
Also *print-radix* and *print-base*, but you can bypass all three
without the overhead of with-standard-io-syntax with this simple
idiom:
(format nil "~d~d" 'X 0)
"Steven M. Haflich" <·················@alum.mit.edu> writes:
> Louis Theran wrote:
> > This is sensitive to the value of *print-case*, at least.
> Also *print-radix* and *print-base*, but you can bypass all three
> without the overhead of with-standard-io-syntax with this simple
> idiom:
>
> (format nil "~d~d" 'X 0)
Since ~d falls back to ~a, this doesn't address the *print-case*
issue. For example, the following probably isn't the desired result.
? *print-case*
:downcase
? (intern (format nil "~d~d" 'X 0))
\x0
nil
? (eq 'x0 *)
nil
? (eq '|x0| **)
t
^L
From: Joe Marshall
Subject: Re: how to convert a number to a string?
Date:
Message-ID: <vftikehq.fsf@ccs.neu.edu>
lama <····@yahoo.com> writes:
> I am trying to concatenate a symbol and number into a symbol. I am
> kinda a newbie so I am not that familiar with lisp API. Here is how i
> thought about doing it.
>
> A - convert the symbol to a string.
> B - convert the number to a string.
> C - concatenate the two above values.
> D - Intern the resulting string.
Intern the resulting string in what package?
Something like this?
(string (digit-char 2))
"lama" <····@yahoo.com> wrote in message
·················@news-int.gatech.edu...
> I am trying to concatenate a symbol and number into a symbol. I am kinda
> a newbie so I am not that familiar with lisp API. Here is how i thought
> about doing it.
>
> A - convert the symbol to a string.
> B - convert the number to a string.
> C - concatenate the two above values.
> D - Intern the resulting string.
>
> I can do steps A, C, D using symbol-name, concatenate, and Intern
> functions respectively. However I don't know of a function that converts
> a number to a string. So help me out here with step B...
>
> Also is there another way of doing all of this.
>
> Thanx.
>